jqgrid reloadGrid 与 loadonce 设置为 true [英] jqgrid reloadGrid with loadonce set to true

查看:17
本文介绍了jqgrid reloadGrid 与 loadonce 设置为 true的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在一页中使用了两个 jqgrid.第二个网格我使用了 loadonce: true 因为我需要在第二个网格中进行列排序.服务器回发后,我需要重新加载两个网格.(需要在第二个网格中显示更新的值).第一个网格重新加载很好,因为它不会使用 loadonce 属性.我的问题是我们可以同时使用 loadonce 属性和 reloadGrid 吗?(通过将 loadonce 属性动态设置为网格)或者在这种情况下我是否需要进行服务器端排序?请指教.提前致谢.

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.

推荐答案

如果你使用 loadonce:true jqGrid 在第一次加载后将 datatype 参数更改为 'local'来自网格的数据.所有下一个网格重新加载(排序、分页、过滤)都在本地工作.如果您想再次从服务器刷新网格数据,您应该将 datatype 设置为其原始值('json' 或 'xml').例如:

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

更新: Free jqGrid 支持 fromServer: true 选项reloadGrid 从第一个版本开始(从版本 4.8 开始).所以可以使用类似的代码

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 });

执行与上述相同的操作.主要优点:此类代码适用于任何初始值 datatype ("json", "jsonp", "xml" 等).免费 jqGrid 在将其更改为 "local" 之前将 datatype 的原始值保存在内部 dataTypeOrg 中.

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".

free jqGrid的另一个有用的选项是navGrid的参数reloadGridOptions,它允许指定reloadGrid的默认选项.因此可以使用例如

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 } }

jqGrid 的选项,另外为 navGrid 设置默认值.结果,点击导航栏的重新加载"按钮将从服务器重新加载网格,而不是本地重新加载.

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 reloadGrid 与 loadonce 设置为 true的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆