【问题标题】:ShieldUI Grid - Adding Columns at run-timeShieldUI Grid - 在运行时添加列
【发布时间】:2015-10-15 16:50:46
【问题描述】:

是否可以在运行时添加列?假设我有一组分页数据,在第 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

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

【问题讨论】:

    标签: shieldui


    【解决方案1】:

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

    然后,当加载网格时,通过使用此函数隐藏第一页不应该可见的列: http://www.shieldui.com/documentation/grid/javascript/api/methods/hideColumn

    然后为网格寻呼机附加一个“更改”事件句柄:

    $("#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
        // ...
    });
    

    【讨论】:

    • 在获取记录之前,不会知道要为所有页面显示的列。可能有超过 15,000 条记录,通过 Web 服务从服务器检索这些数据需要 1-2 分钟。
    • 您可以在获取数据后进行初始化 - 有“dataBound”事件用于捕获。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-11-02
    • 2011-10-21
    • 1970-01-01
    • 2015-12-14
    • 2010-11-02
    • 1970-01-01
    相关资源
    最近更新 更多