Here is the jqGrid code snippet that I am working with:
$("#report").jqGrid( {
url: '/py/db?coll=report',
datatype: 'json',
height: 250,
colNames: ['ACN', 'Status', 'Amount'],
colModel: [ {name:'acn', sortable:true},
{name:'meta.status', sortable:true},
{name:'amount'} ],
caption: 'Show Report',
rownumbers: true,
gridview: true,
rowNum: 10,
rowList: [10,20,30],
pager: '#report_pager',
viewrecords: true,
sortname: 'acn',
sortorder: "desc",
altRows: true,
loadonce: true,
mtype: "GET",
rowTotal: 1000,
jsonReader: {
root: "rows",
page: "page",
total: "total",
records: "records",
repeatitems: false,
id: "acn"
}
});
The issue arises from using JSON dot notation in the column 'meta.status' and the corresponding data received from the server:
{"page": "1", "total": "1", "records": "5", "rows": [
{"acn":1,"meta": {"status":"Confirmed"}, "amount": 50},
{"acn":2,"meta": {"status":"Started"}, "amount": 51},
{"acn":3,"meta": {"status":"Stopped"}, "amount": 52},
{"acn":4,"meta": {"status":"Working"}, "amount": 53},
{"acn":5,"meta": {"status":"Started"}, "amount": 54} ] }
There are two main challenges encountered:
- Sorting functionality does not operate on columns with dot notation, such as "meta.status". The sortable icons do not appear on the column header, and clicking on the header does not trigger any sorting action, regardless of whether loadonce is set to true or false.
- If attempting to perform a Search operation (with loadonce set to true) on the column meta.status (other columns without dot notation work fine), it results in a JavaScript error being thrown.