prime February 2016

Can trigger(“reloadGrid”) works when 'loadonce: true' in jqGrid?

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 reloadi

Answers


Oleg February 2016

First of all I would strictly recommend you to upgrade jqGrid which you use from version 4.4.0 to free jqGrid 4.12.1. Free jqGrid is the fork of jqGrid which I develop starting with end of 2014. See the post and the link from UPDATED part of the answer for additional information. You should understand that jqGrid 4.4.0 is really retro version. It was published at the time of jQuery 1.4.3 version. It was the time when IE9 was the latest version of Internet Explorer, but IE6-IE8 was the mostly used versions. Now we have another time in web development.

It's important to understand what do loadonce: true and what do .trigger('reloadGrid').

jqGrid support local holding of data inside of JavaScript objects. One can use datatype: "local", provides the data using data parameter and then work with the data using local paging, sorting and filtering the data. You can change the values of page size (rowNum), page number (page) and sorting parameters (sortname, sortorder) and reload the current displayed page using the new options by triggering reloadGrid event. jqGrid will sort the data and displays the requested page. Thus it's important to understand that .trigger('reloadGrid') works with local data too.

If you use datatype:'xml' together with loadonce: true then the server have to return all data. The data have to be sorted by requested sortname, sortorder options only (the parameters sidx and sord of the request to the server). Thus jqGrid fills internal data parameter with all the data. jqGrid displays the first page of returned data (based

Post Status

Asked in February 2016
Viewed 3,728 times
Voted 11
Answered 1 times

Search




Leave an answer