【问题标题】:Local gridfilters本地网格过滤器
【发布时间】:2020-08-05 07:23:24
【问题描述】:

在 ExtJS 4 中,我可以创建一个过滤器来过滤我的网格。 当本地设置为 false 时,我可以过滤我的商店。

var filtersCfg = {
    ftype: 'filters',
    autoReload: false, //don't reload automatically
    local: false, //remote filter
    // filters may be configured through the plugin,
    // or in the column definition within the headers configuration
    filters: [{
        type: 'numeric',
        dataIndex: 'id'
    }, {
        type: 'string',
        dataIndex: 'name'
    }, {
        type: 'numeric',
        dataIndex: 'price'
    }, {
        type: 'date',
        dataIndex: 'dateAdded'
    }, {
        type: 'list',
        dataIndex: 'size',
        options: ['extra small', 'small', 'medium', 'large', 'extra large'],
        phpMode: true
    }, {
        type: 'boolean',
        dataIndex: 'visible'
    }]
};

在 EXTJS 7 中我只能添加一个插件:

plugins: {
         gridfilters: true
    },

如何在 EXTJS 7 中添加远程过滤器。这仍然可能吗?我在文档中找不到任何内容。

最好的问候

编辑:

我正在使用 data.Store 从我的 php/数据库中获取 json。在网格上排序不是问题。但是如何使用过滤器将参数发送到我的 php?

var Store = new Ext.data.Store({
            extend: 'Ext.data.Store',
            autoLoad: true,
            remoteSort: true,
            fields: [
                'columnA','columnB'
            ],
            pageSize : 50,
            proxy: {
                type: 'ajax',
                actionMethods: {
                    create : 'POST',
                    read   : 'POST',
                    update : 'POST',
                    destroy: 'POST'
                },
                url: 'data/URL.php',
                reader: {
                    rootProperty: 'columns',
                    totalProperty: 'totalCount'
                },
                simpleSortMode: true,
                extraParams: {
                    task: 'doFiltering'
                }
            },
        sorters: [{
            property: 'columnA',
            direction: 'DESC'
        }]
    });

【问题讨论】:

    标签: extjs extjs4 extjs7


    【解决方案1】:

    我找到了解决办法。

    我需要将 remoteFilter: true 添加到我的 store。 我一直在寻找错误的地方。

    这是解决方案:How to apply filter function to paging grid with local(memory) store in ExtJS6?

    感谢您的帮助。

    【讨论】:

      【解决方案2】:

      在 ExtJS 7 中,您必须将 filter 配置放入 column

      ...
          {
              text: 'Email',
              dataIndex: 'email',
              flex: 1,
              filter: {
                  type: 'string',
                  value: 'lisa'
              }
          },
      ...
      

      Fiddle

      【讨论】:

      • 您好,谢谢,但这也只是一个本地过滤器。我正在使用带有代理的商店从 mysql 数据库中获取我的值。我有超过 10.000 行。我使用 pagingtoolbar 插件只显示 50 行 (pageSize:50)。远程排序没问题。但我需要一个函数来使用数据库过滤我的网格。
      • 哦,你需要远程过滤吗?
      • 对于远程过滤,将 porperty remoteFilter (docs.sencha.com/extjs/6.5.0/classic/…) 设置为 true
      • 是的,我正在尝试将遥控器添加到我的过滤器中。就像在 EXTJS 4 中一样。在 ExtJS7 中,我需要将其添加到商店中。
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-09-24
      • 1970-01-01
      • 1970-01-01
      • 2013-05-20
      相关资源
      最近更新 更多