首页 > 其他 > 详细

[jqGrid]关于loadonce:true后trigger("reloadGrid")无效,loadonce:false后无法翻页的问题(来自stackoverflow)

时间:2016-03-28 13:41:26      阅读:1225      评论:0      收藏:0      [点我收藏+]

简单的来说就是在setGridParam中加上参数datatype:‘json‘,因为loadonce:true后,jqGrid只会加载一次数据,并把datatype改为local,这样就无法完成于Server的交互通信进行数据搜索和刷新操作,因为全部数据都是提取的本地的,所以在刷新的时候重新将datatype重新定位到json,也就是指向服务器后,jqGrid就会像服务器发起请求。

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

以上方法亲测可用

 

或者在jqGrid version 4.8之后,在trigger中加上参数fromServer:true,

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

此方法未测试,只是原文中提到了。

 

附送原文:

原文地址:http://stackoverflow.com/questions/5397671/jqgrid-reloadgrid-with-loadonce-set-to-true/5398136#5398136

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.

[jqGrid]关于loadonce:true后trigger("reloadGrid")无效,loadonce:false后无法翻页的问题(来自stackoverflow)

原文:http://www.cnblogs.com/wumingpu/p/5328658.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!