The jqGrid source file I'm using says at the top it's version as jqGrid 4.4.0
, date as Date 2012-06-14
In this wiki page it says that trigger(“reloadGrid”)
,
Reloads the grid with the current settings. This means that a new request is send to the server if datatype is xml or json. This method should be applied to an already-constructed grid. Pay attention that this method does not change HEADER information, that means that any changes to colModel would not be affected. You should use gridUnload to reload new configuration with different colModel. IT'S WORK ONLY IF loadonce: false !!!
And yes it says "IT'S WORK ONLY IF loadonce: false !!!"
And this SO answer suggest some hack for that. It says,
If you use loadonce:true jqGrid change the datatype parameters to 'local' after the first load of data from the grid. All next grid reloading (sorting, paging, filtering) works local. If you want refresh the grid data from the server one more time you should set datatype to its original value ('json' or 'xml').
So that answer actually solved a problem I was facing. I had a jqGrid which has loadonce:true
. (here I care about the sorting and it worked perfectly). but then I had to change the code a bit to reload the jqGrid with new server data. (user can change some details and refresh the table so the jqGrid should reload the newly aquired data from the server). Unfortunately this didn't work until I changed loadonce:true
to loadonce:false
.
I called the reloading as this,
$("#tableGrid").setGridParam({url:'myUrl'}).trigger('reloadGrid');
Now the reloading was fine. BUT the sorting was gone :(
And then I saw that SO answer and change it to something like this,
I set loadonce:true
when initializing the grid.
and called the reloading as below.
$("#tableGrid").setGridParam({url:'myUrl',datatype:'xml'}).trigger('reloadGrid');
after that all the sorting was fine and user can reload the grid as well.
Is this approach correct ? I think it solved the problem, but is it ? because the documentation says you can't reload when loadonce:true
?