簡單的來講就是在setGridParam中加上參數datatype:'json'
,由於loadonce:true後,jqGrid只會加載一次數據,並把datatype改成local,這樣就沒法完成於Server的交互通訊進行數據搜索和刷新操做,由於所有數據都是提取的本地的,因此在刷新的時候從新將datatype從新定位到json,也就是指向服務器後,jqGrid就會像服務器發起請求。git
例如:$("#list").setGridParam({datatype:'json', page:1}).trigger('reloadGrid');
github
以上方法親測可用json
或者在jqGrid version 4.8以後,在trigger中加上參數fromServer:true,服務器
例如:$("#list").trigger("reloadGrid", { fromServer: true, page: 1 });
ide
此方法未測試,只是原文中提到了。post
附送原文:測試
原文地址:http://stackoverflow.com/questions/5397671/jqgrid-reloadgrid-with-loadonce-set-to-true/5398136#5398136jsonp
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:spa
$("#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 likecode
$("#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.