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

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

问题描述

我在一页中使用了两个jqgrids.第二个网格我使用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参数更改为本地".接下来的所有网格重新加载(排序,分页,过滤)都在本地进行.如果要再次刷新服务器中的网格数据,则应将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');

更新:免费jqGrid 支持reloadGridfromServer: true选项,从第一版(从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将datatype的原始值保存在内部dataTypeOrg内部,然后将其更改为"local".

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

免费的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.

这篇关于将loadonce设置为true的jqgrid reloadGrid的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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