【发布时间】:2016-05-18 04:18:05
【问题描述】:
我正在使用的 jqGrid 源文件在顶部显示它的版本为 jqGrid 4.4.0 ,日期为 Date 2012-06-14
在这个wiki page 中说trigger(“reloadGrid”),
Reloads the grid with the current settings. This means that a new request is send to the server if datatype is xml or json. This method should be applied to an already-constructed grid. Pay attention that this method does not change HEADER information, that means that any changes to colModel would not be affected. You should use gridUnload to reload new configuration with different colModel. IT'S WORK ONLY IF loadonce: false !!!
是的,它说 “仅当 loadonce: false !!!”时才有效!
this SO answer 建议对此进行一些破解。它说,
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').
所以这个答案实际上解决了我面临的一个问题。我有一个具有loadonce:true 的 jqGrid。 (在这里我关心排序,它工作得很好)。但后来我不得不稍微更改代码以使用新的服务器数据重新加载 jqGrid。 (用户可以更改一些细节并刷新表格,以便 jqGrid 重新加载从服务器获取的新数据)。不幸的是,直到我将loadonce:true 更改为loadonce:false,这才奏效。
我称之为重载,
$("#tableGrid").setGridParam({url:'myUrl'}).trigger('reloadGrid');
现在重新加载很好。但是排序消失了:(
然后我看到了 SO 的答案并将其更改为这样的内容,
我在初始化网格时设置了loadonce:true。
并如下调用重新加载。
$("#tableGrid").setGridParam({url:'myUrl',datatype:'xml'}).trigger('reloadGrid');
之后所有的排序都很好,用户也可以重新加载网格。
这种方法正确吗?我认为它解决了问题,但是是这样吗? 因为文档说你不能在 loadonce:true 时重新加载?
【问题讨论】:
标签: javascript jqgrid