Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to disable autoload in jqGrid?

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

Thanks.

like image 410
andser Avatar asked Jul 17 '10 12:07

andser


2 Answers

If you set datatype to 'local' the data from the server will be not loaded. To force the loading of data you can change datatype to 'json' or 'xml' with respect of 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 trigger("reloadGrid") method.

See jqGrid is not loading data which has also the information what you asked.

like image 95
Oleg Avatar answered Sep 25 '22 21:09

Oleg


Just don't set the default URL in the table. And install it just when you need to load data (for example by pressing a button) and then .trigger("reloadGrid").

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');
         }
like image 36
Igor Avatar answered Sep 24 '22 21:09

Igor