Hi, thanks for this. Ive amended the example code and the column headings and sorting is working. The external data isnt loading though. Below is my code with the external JSON format at the bottom. Thanks.
Edit: Please note, I am using ASP.Net aspx (web forms) and not HTML. Would this make any difference to the callbacks?
<script type="text/javascript">
$(function () {
var colM = [
{ title: "Model", width: 300, dataType: "string" },
{ title: "Repayments", width: 100, dataType: "integer", align: "right" },
{ title: "Term", width: 100, dataType: "integer", align: "right" },
{ title: "CapID", width: 100, dataType: "integer", align: "right" },
];
var dataModel = {
location: "remote",
sorting: "remote",
paging: "remote",
dataType: "JSON",
method: "GET",
curPage: 1,
rPP: 20,
sortIndx: 2,
sortDir: "up",
rPPOptions: [1, 10, 20, 30, 40, 50, 100, 500, 1000],
getUrl: function () {
var sortDir = (this.sortDir == "up") ? "asc" : "desc";
var sort = ['Model', 'Repayments', 'Term', 'CapID'];
return { url: "js/vehicles.json", data: "cur_page=" + this.curPage + "&records_per_page=" +
this.rPP + "&sortBy=" + sort[this.sortIndx] + "&dir=" + sortDir };
},
getData: function (dataJSON) {
//var data=
return { curPage: dataJSON.curPage, totalRecords: dataJSON.totalRecords, data: dataJSON.data };
}
}
var grid1 = $("div#grid_paging").pqGrid({ width: 900, height: 400,
dataModel: dataModel,
colModel: colM,
title:"Shipping Orders",
resizable: true,
columnBorders: true,
freezeCols: 2
});
});
</script>
js/vehicles.json
[
{
"Model":"A1 HATCHBACK 1.2 TFSI S Line ",
"Repayments":"£209",
"Term":"6 Month",
"CapID":1234
},
{
"Model":"A1 HATCHBACK 1.2 TFSI Sport ",
"Repayments":"£189",
"Term":"6 Month",
"CapID":5678
},
{
"Model":"A1 HATCHBACK 1.4 TFSI 140 S Line ",
"Repayments":"£229",
"Term":"12 Month",
"CapID":5678
},
{
"Model":"A1 HATCHBACK 1.4 TFSI 140 S Line S Tronic",
"Repayments":"£239",
"Term":"6 Month",
"CapID":5678
}
]