如何在free jqgrid中将remapColums替换为remapColumnsByName
用于保存jqgrid状态。它使用列号保存jqgrid列状态。如果在服务器中更改了jqgrid colmodel,则会在浏览器中导致javascript错误。
JQGrid注释中的冻结rownum列和https://github.com/free-jqgrid/jqGrid/blob/master/README49.md描述了方法remapColumnsByName
。我希望使用它修复issUe。
免费的jqgrid是从今天的git master下载的。在列调整大小或移动行后的状态保存
saveColumnState.call($grid, $grid[0].p.remapColumns);
被改为
saveColumnState.call($grid, $grid[0].p.remapColumnsByName);
并在loadComplete代码中恢复状态
if (isColState && myColumnsState.permutation.length > 0 && myColumnsState.permutation.length === cm.length) { $grid.jqGrid("remapColumns", myColumnsState.permutation, true); }
同
if (isColState && myColumnsState.permutation.length > 0 && myColumnsState.permutation.length === cm.length) { $grid.jqGrid("remapColumnsByName", myColumnsState.permutation, true); }
现在排队
if (isColState && myColumnsState.permutation.length > 0 &&
导致错误
Uncaught TypeError: Cannot read property 'length' of undefined
如何修复此问题,以便在更改列定义时可以使用列状态?
方法定义为
var saveColumnState = function (perm) { var colModel = this.jqGrid('getGridParam', 'colModel'), i, l = colModel.length, colItem, cmName, postData = this.jqGrid('getGridParam', 'postData'), columnsState = { search: this.jqGrid('getGridParam', 'search'), page: this.jqGrid('getGridParam', 'page'), rowNum: this.jqGrid('getGridParam', 'rowNum'), sortname: this.jqGrid('getGridParam', 'sortname'), sortorder: this.jqGrid('getGridParam', 'sortorder'), autoedit: autoedit, rownumbers: $grid.jqGrid('getGridParam', 'rownumbers') && !$grid[0].p.colModel[0].hidden, searchWindow: searchParams, editWindow: editParams, permutation: perm, selectedRows: idsOfSelectedRows, colStates: {} }, colStates = columnsState.colStates; if (typeof (postData.filters) !== 'undefined') { columnsState.filters = postData.filters; }
相关分类