Forum

July 10th, 2011
You must be logged in to post Login Register

Search Forums:


 






How to trigger initial client side sorting

No Tags
UserPost

01:50
13/05/2012


twilson7755

New Member

posts 1

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
25/05/2012


Arvind Yadav

Member

posts 11

Post edited 22:18 – 25/05/2012 by Arvind Yadav
Post edited 22:18 – 25/05/2012 by Arvind Yadav


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,

No Tags

About the jQuery Grid Plugin – jqGrid forum

Most Users Ever Online:

157


Currently Online:

83 Guests

Forum Stats:

Groups: 1

Forums: 7

Topics: 9662

Posts: 28951

Membership:

There are 10357 Members

There have been 448 Guests

There is 1 Admin

There are 2 Moderators

Top Posters:

OlegK – 1167

markw65 – 179

kobruleht – 144

phicarre – 126

YamilBracho – 124

Renso – 118

Administrators: admin (56 Posts)

Moderators: tony (7043 Posts), Rumen[Trirand] (81 Posts)




Comments are closed.
Privacy Policy   Terms and Conditions   Contact Information