【问题标题】:shieldUI grid filter / sort persistence on grid refreshshieldUI网格过滤器/网格刷新排序持久性
【发布时间】:2016-12-06 02:29:00
【问题描述】:

是否可以以某种智能优化的方式在 grid.refresh() 上保持网格排序/过滤/选择?我需要在窗口调整大小事件上刷新网格以调整到新的窗口大小。我猜刷新内部会破坏并重新创建网格,而不考虑可能的活动排序/过滤/选择。因为网格可以包含大量数据(虚拟滚动),我想避免不必要的数据库查询、渲染和排序。我想我正在寻找可以刷新现有数据的刷新。

【问题讨论】:

    标签: sorting filter grid selection shieldui


    【解决方案1】:

    就像他们刚刚实现的接缝一样 - 这是example

    可能会包含在下一个版本中。

    这是示例中的代码:

    jQuery(function ($) {
        $("#grid").shieldGrid({
            dataSource: {
                data: gridData,
                schema: {
                    fields: {
                        id: { type: Number },
                        name: { type: String },
                        company: { type: String },
                        phone: { type: String },
                        age: { type: Number },
                        gender: { type: String }
                    }
                },
                filter: {
                    // create the initial filter in that form
                    and: [
                        { path: "name", filter: "con", value: "John" }
                    ]
                }
            },
            filtering: {
                enabled: true
            },
            paging: true,
            columns: [
                { field: "id", width: "250px", title: "ID" },
                { field: "name", title: "Person Name", width: "250px" },
                { field: "company", title: "Company" },
                { field: "phone", title: "Phone", width: "250px" },
                { field: "age", title: "Age" }
            ]
        });
    });
    

    【讨论】:

    • 请使用该示例发布您的答案。
    【解决方案2】:

    我自己在刷新方法中找到了解决方案。它接受选项对象,人们可以在其中提供当前数据源选项以保持不变。持久排序和/或过滤的示例:

    var options = {
        dataSource: $("#grid").swidget().dataSource
    }
    $("#grid").swidget().refresh(options);
    

    如果我在这里错了,请纠正我。对于选择,我想可以在调用刷新后检索选定的索引并重新选择。

    编辑:过滤器和排序被保留,但过滤器行重置(丢失所有活动输入值)。这可能是一个错误吗?如何将值保留在过滤器行中?

    【讨论】:

      猜你喜欢
      • 2010-12-16
      • 2011-08-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-01-12
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多