如何在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;
}
添加回答
举报
0/150
提交
取消