Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jqgrid reloadGrid with loadonce set to true

Tags:

jquery

jqgrid

I am using two jqgrids in one page. second grid i used loadonce: true since i need column sort in the second grid. i need to reload both grids after a server post back. (need to show updated value in the second grid). first grid reload fine since it won't use the loadonce attribute. my question is can we use loadonce attribute and reloadGrid together? ( by setting loadonce attribute dynamically to the grid) or else do i need to go for a server side sorting in this case? please advice. Thanks in advance.

like image 576
Sam Avatar asked Mar 22 '11 20:03

Sam


People also ask

What is Loadonce in jqGrid?

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').

How do I reset jqGrid?

jqGrid('clearGridData') . jqGrid('setGridParam', {data: data, page: 1}) . trigger('reloadGrid'); } } }); )};


1 Answers

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'). For example:

$("#list").setGridParam({datatype:'json', page:1}).trigger('reloadGrid');

UPDATED: Free jqGrid supports fromServer: true option of reloadGrid starting with the first release (starting with version 4.8). So one can use the code like

$("#list").trigger("reloadGrid", { fromServer: true, page: 1 });

to do the same as above. The main advantage: such code works fine with any initial value of datatype ("json", "jsonp", "xml" and so on). Free jqGrid saves original value of datatype inside of internal dataTypeOrg before changing it to "local".

One more helpful option of free jqGrid is the parameter reloadGridOptions of navGrid, which allows to specify default options of reloadGrid. Thus one can use for example

loadonce: true,
navOptions: { reloadGridOptions: { fromServer: true } }

options of jqGrid, which set defaults for navGrid additionally. As the result the click on "Reload" button of navigator bar will reload the grid from the server instead of local reloading.

like image 130
Oleg Avatar answered Sep 28 '22 09:09

Oleg