Forum
21:29
07/04/2014
I recently updated a project from JQGrid 4.2.0 to 4.6.0 and sort is not working. I also implemented bootstrap 3.0 and didn't make any code changes other than some minor styling so I would assume it should work but it is not. Everything else appears to be working fine except sorting. I did some research online and the common solution appears to be to set loadonce to true and I've tried this and sorting works fine. However, I cannot set loadonce to true since our data sets can exceed 50,000 so multilple loads will be required. Some code snippets is listed below. Thanks in advance.
var colNames = ['', '', '..', 'Name', 'Age', '...', '...', '...'];
colNames.push('Final Time', '', '', '');
var colModel = [
...
{ name: 'Name', index: 'Name', editable: true },
{ name: 'Age', index: 'Age', width: 30, align: 'center', editable: true },
....
];
// for(var j = 0; j < legIds.length; j++) {
// colModel.push({ name: 'Leg' + (j + 1), index: 'Leg' + (j + 1), editable: true, width: 70, align: 'right' });
// }
...
grid = $("#grid");
grid.jqGrid({
url: '/Results/GetData?&courseid=' + courseID,
prmNames: {
rows: 'pageSize',
sort: 'sortOrder',
order: 'sortDir',
nd: null
},
datatype: 'json',
jsonReader : {
id : 'ID',
root: 'entries',
repeatitems: false
},
colNames: colNames,
colModel: colModel,
height: 'auto',
autowidth: true,
altRows: false,
caption: '',
cellEdit: false,
cellsubmit: 'clientArray',
grouping: true,
toolbar: [false, 'top'],
pager: '#pager',
toppager: false,
rowNum: 25,
// rowTotal: 50,
rowList: [25, 50, 100, 250],
viewrecords: true,
onSelectRow: onGridSelectRow,
ondblClickRow: onGridDblClickRow,
onPaging: onGridPaging,
loadComplete: onGridLoadComplete
});
11:30
Moderators
30/10/2007
Hello,
If you use loading a data from the server you should know that in this case the sorting is on the server and not in the grid.
In this case you will need to make your server side code so that if the grid perform sort you should send the appropriate sorted data to the grid.
In case of loadonce = true you actually tell the grid to load data locally and in this case the grid sort the data automatically for you.
Some example you can see in our documentation site This is in PHP, but you will get a idea how to do this.
Kind Regards
Tony
For professional UI suites for Java Script and PHP visit us at our commercial products site - guriddo.net - by the very same guys that created jqGrid.
Most Users Ever Online: 715
Currently Online:
63 Guest(s)
Top Posters:
OlegK: 1255
markw65: 179
kobruleht: 144
phicarre: 132
YamilBracho: 124
Renso: 118
Member Stats:
Guest Posters: 447
Members: 11373
Moderators: 2
Admins: 1
Forum Stats:
Groups: 1
Forums: 8
Topics: 10592
Posts: 31289
Newest Members:
, razia, Prankie, psky, praveen neelam, greg.valainis@pa-tech.comModerators: tony: 7721, Rumen[Trirand]: 81
Administrators: admin: 66