Jqgrid Sort Column

Is it possible to dynamically sort a single jqGrid column when a button is clicked, rather than clicking on the column name?

+4
source share
3 answers

In the button click event, set the sort column in the grid postdates, and then call reboot in the grid

$('#mybutton').click(function() { $('#yourgrid').jqGrid('setGridParam', {sortname: 'yourColumn', sortorder: 'asc'}).trigger('reloadGrid', [{page: 1}]); }); 
+6
source

For the fourth time even lucky !. Using true in the third parameter will surely reload the grid.

 $('#grid').jqGrid('sortGrid', 'id', true, 'asc'); 

If you do not use true in the third parameter, in the first execution the order ('asc' or 'desc') is not updated correctly.

+8
source

Possible solution - but not very:

 $('#grid').jqGrid('setGridParam', {sortname: 'id', sortorder: 'asc'}).trigger('reloadGrid', [{page: 1}]); $('#gbox_grid .s-ico').css('display','none'); $('#gbox_grid #jqgh_grid_id .s-ico').css('display',''); $('#gbox_grid #jqgh_grid_id .s-ico .ui-icon-triangle-1-s').removeClass('ui-state-disabled'); 

as shown here

http://jsfiddle.net/qhYLT/


Another way to sort by column programmatically is by specifying the order:

 $('#grid').jqGrid('setGridParam', {sortorder: 'desc'}); $('#grid').jqGrid('sortGrid', 'id'); 

SortGrid launches a reboot for you. This would not be complete without a demo: http://jsfiddle.net/uTqD5/


The third time, lucky! Undocumented function:

 $('#grid').jqGrid('sortGrid', 'id', '', 'asc'); 
+3
source

Source: https://habr.com/ru/post/1399177/


All Articles