Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

programmatically sorting the jqGrid

Tags:

jquery

jqgrid

I have a jqGrid populated with data, but I want to change how this is shown by editing the CSS.

So far so good, but I'm trying to have a dropdownlist which, when changed, will sort the jqGrid based on the value selected.

Is there anyway to actually call the sort function programmatically?

I have tried the following which, does nothing:

$("#grid").jqGrid('setGridParam',{sortname: 'yearEdition,', sortorder: 'desc'});
$("#grid").trigger("reloadGrid");

Is there indeed a way to call this event?

like image 770
JasonMHirst Avatar asked Dec 31 '25 11:12

JasonMHirst


1 Answers

You should use sortGrid method of jqGrid:

Sorts the given colname and shows the appropriate sort icon. The same (without sorting icon) can be done using setGridParam({sortname:'myname'}).trigger('reloadGrid'). If the reload is set to true, the grid reloads with the current page and sortorder settings.

like image 161
Oleg Avatar answered Jan 02 '26 00:01

Oleg