I have a grid that I am retrieving the entire set of data for, then want the users to have the ability to sort the resulting data. I am using the following attributes, but the grid does not sort. It's also worth mentioning after the user clicks a button, I will make an AJAX call then I will need to refresh from the source, but since I'm pulling all of the data to the client every time, I shouldn't need to go back to the server just to sort.
loadonce: true, // to enable sorting on client side
sortable: true //to enable sorting
Any suggestions are greatly appreciated!
I just noticed something. You can use the loadComplete parameter when defining the grid.
loadComplete: function() {
// add a function here that waits for a short amount of time, like 100msecs
jQuery("#list1").jqGrid('setGridParam', {
datatype:'local',
sortname:'name',
sortorder:'asc',
page:1
}).trigger("reloadGrid");
}
Note that I use my data locally and when I need a refresh put the datatype back to xml.
Important: this in itself will not work: you need to have a small amount of time waiting before triggering reloadGrid(executing the line). Otherwise you won't see a difference in the output.
I'm not sure but it seems to me that you want to achieve your sorting locally whereas your searches remotely. I had the same requirement and I did it like this: Make 'Search' remote and everything else (sorting, pagination, etc) local in jqGrid
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With