How to disable autoload in jqGrid?

How to disable autoload in jqGrid and load data manually when I need it?

Thanks.

+6
javascript manual autoload jqgrid
source share
4 answers

If you set datatype to 'local' , data from the server will not be downloaded. To force the data to load, you can change the datatype to 'json' or 'xml' with respect to the setGridParam method (see http://www.trirand.com/jqgridwiki/doku.php?id=wiki:options and http: / /www.trirand.com/jqgridwiki/doku.php?id=wiki:methods#grid_related_methods ), and then call the trigger("reloadGrid") method trigger("reloadGrid") .

See jqGrid does not load data , which also contains information about what you requested.

+10
source share

Just don't set the default url in the table. And install it only when you need to download data (for example, by clicking a button) and then .trigger("reloadGrid") .

An example for you:

 jQuery("#grid").jqGrid( { //Simply comment out the URL //url :"salepointsprovider.php", datatype:"json", colModel :[ {name:'SalePointId', index:'SalePointId'}, {name:'Name', index:'Name'} ] } $('#ShowRecordsButton').click(function () { jQuery("#grid").jqGrid('setGridParam', {url:"salepointprovider.php?SalePointId=" + argSalePointId, page:1}); jQuery("#grid").trigger('reloadGrid'); } 
+2
source share

My grid without url sends requests to the server:

... / _ search = false &? D = 1370817124473 & rows = 20 & page = 1 & sidx = & Sord = ascending

Set data type: β€œlocal” solution problem. Reload grid

  `function reloadGrid (gridId, gridData) {
     $ (gridId) .jqGrid ('clearGridData');  // need for nonempty grig (see http://www.trirand.com/blog/?page_id=393/help/triggerreloadgrid-not-work/)
     $ (gridId) .jqGrid ('setGridParam', {data: gridData}). trigger ('reloadGrid');
 }
 ` 

No need to change data type (at least for my json case it is recognized)

0
source share

In treegrid you cannot use datatype = 'local'. So instead of "local" I set datatype = 'jsonstring', defines empty fake data and jsonReader. jsonReader should be defined correctly according to your data. Thanks for Oleg answer . And, when I need to load data, I just change the data type to "json".

 var fakeData ={ rows: [] }; ... datatype: 'jsonstring', datastr: fakeData, ... jsonReader: { repeatitems: false, root: function (obj) { return obj.rows; }, page: function (obj) { return 1; }, total: function (obj) { return 1; }, records: function (obj) { return obj.length; } } 
0
source share

All Articles