在网格中过滤 header extjs 6

Filter in grid header extjs 6

如何在网格中创建过滤器headers?

我找到了这个片段: 并更新为与第 6 版兼容:

Ext.define('Fiddle.view.SearchTrigger', {
    extend: 'Ext.form.field.Text',
    alias: 'widget.searchtrigger',

    requires: [
        'Ext.form.trigger.Trigger'
    ],

    defaultListenerScope: true,

    triggers: {
        search: {
            handler: function(field, trigger, e) {
                this.setFilter(this.up().dataIndex, this.getValue());
            },
            cls: 'x-form-search-trigger'
        },
        clear: {
            handler: function(field, trigger, e) {
                this.setValue('');
                if(!this.autoSearch) this.setFilter(this.up().dataIndex, '');
            },
            cls: 'x-form-clear-trigger'
        }
    },
    listeners: {
        render: 'onTextfieldRender',
        change: 'onTextfieldChange'
    },

    onTextfieldRender: function(component, eOpts) {
        var me = this;
        me.ownerCt.on('resize', function(){
            me.setWidth(this.getEl().getWidth());
        });
    },

    onTextfieldChange: function(field, newValue, oldValue, eOpts) {
        if(this.autoSearch) this.setFilter(this.up().dataIndex, this.getValue());
    },

    setFilter: function(filterId, value) {
        var store = this.up('grid').getStore();
        if(value){
            store.removeFilter(filterId, false);
            var filter = {id: filterId, property: filterId, value: value};
            if(this.anyMatch) filter.anyMatch = this.anyMatch;
            if(this.caseSensitive) filter.caseSensitive = this.caseSensitive;
            if(this.exactMatch) filter.exactMatch = this.exactMatch;
            if(this.operator) filter.operator = this.operator;
            console.log(this.anyMatch, filter);
            store.addFilter(filter);
        } else {
            store.filters.removeAtKey(filterId);
            store.reload();
        }
    }

});

最难的地方-列中创建带有小部件的项目。 我无法在 Sencha Fiddle 中重现它。怎么做?

首先登录Sencha Fiddle using the Sencha Forum credentials. After this, copy-paste your code and save it. The updated url that you get after saving will be sharable. Please refer here for docs on Sencha Fiddle

固定码:https://fiddle.sencha.com/#view/editor&fiddle/2820