本文介绍了JQGrid列重新排序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试使用remapColumns:

grid.remapColumns(newOrder, false, false);

但遇到一个奇怪的问题-列标题已重新排序,但列信息保持不变.怎么解决呢?

but got a strange issue - column headers was reordered, but column infos stayed untouched. How can solve that?

整个方法

permutateGrid: function (gridID, columnsToShow, columnsToHide) {
    var newOrder = [];
    var grid = $(gridID);

    for (var i = 0; i < columnsToShow.length; i++) {
        newOrder.push(GridHelpers.getColumnSrcIndexByName(grid, columnsToShow[i]));
    }

    var columnsCount = grid.jqGrid("getGridParam", "colModel").length;
    for (var i = 0; i < columnsCount; i++) {
        if (newOrder.indexOf(i) === -1) {
            newOrder.push(i);
        }
    }

    showColumns(gridID, columnsToShow);
    hideColumns(gridID, columnsToHide);

    grid.jqGrid('remapColumns', newOrder, false, false);
    grid[0].jqGrid().updateColumns();
},

推荐答案

如果要更新网格内容,则remapColumns的第二个参数应为true. remapColumns的典型用法是grid.jqGrid("remapColumns", newOrder, true, true);(或grid.remapColumns(newOrder, true);).

The second parameter of remapColumns should be true if you want to update grid content. Typical usage of remapColumns is grid.jqGrid("remapColumns", newOrder, true, true); (or grid.remapColumns(newOrder, true);).

这篇关于JQGrid列重新排序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-11 06:26