Forum


01:50

05/05/2012

I have a grid where the data is loaded once from a server (datatype: json, loadonce: true) and I am able to successfully display the data in the grid and click on the various column headings to trigger sorting. My problem is that the initial data that is returned from the server is NOT sorted and I would like the grid to perform the initial sorting on the client side without having to click a column heading.
I tried adding the following code to the loadComplete event but it had no effect:
loadComplete: function () {
$("#list").jqGrid('setGridParam', { sortname: 'Name', sortorder: 'asc' });
$("#list").trigger("reloadGrid");
},
where 'Name' is the colName that I would like the initial sorting performed on. Any ideas would be greatly appreciated.
Thanks,
Terry
22:13

16/11/2011

Hi,
Define the sortname,sortorder i.e. the column on which you want the default sorting. Then,
Change the datatype of the grid to local on the loadcomplete event of the jqgrid.
2nd option:
1. Fire a ajax call and get the data into a javascript array.
2. Define the jqgrid with datatype local and give the array constructed in step 1 as input to the grid.
3. Define the default sorting column and order
Thanks,
Most Users Ever Online: 715
Currently Online:
155 Guest(s)
Currently Browsing this Page:
1 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