ShieldUI 网格 - 在 运行 时间添加列

ShieldUI Grid - Adding Columns at run-time

是否可以在 运行 时添加列?假设我有一组分页数据,在第 1 页有 4 列,在第 2 页有相同的 4 列加上 1 个不同的列,然后在第 3 页有与第 1 页相同的 4 列,但有 2 列与第 2 页不同。


数据中的第 1 列并显示在网格中:

File, DocName, PrintDate, Event

数据中第 2 列并显示在网格中:

File, DocName, PrintDate, Event, Person

数据中第 3 列:

File, DocName, PrintDate, Event, RunDate, Designation

第 3 页网格中显示的列:

File, DocName, PrintDate, Event, Person, RunDate, Designation

并且在页面之间来回移动时,它们都将保留在网格中。

您可以通过将要在网格中显示的所有列最初添加到所有页面来实现。

然后,在加载网格时,使用以下函数隐藏首页不可见的列: http://www.shieldui.com/documentation/grid/javascript/api/methods/hideColumn

然后为网格寻呼机附加一个 "change" 事件句柄:

$("#grid").swidget().pager.on("change", function(e) {
    var currentPage = this.currentPage;

    // hide the cols not supposed to be visible on this page 
    // and show the rest - using the grid's hideColumn() and 
    // showColumn() functions
    // ...
});