过滤网格头extjs 6 [英] Filter in grid header extjs 6

查看:80
本文介绍了过滤网格头extjs 6的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

How to create a filter in the grid headers?

我找到了以下代码段: https://stackoverflow.com/a/22015160/5775332 并更新为与第六版:

I found this snippet: https://stackoverflow.com/a/22015160/5775332 and updated to compatibility with 6th version:

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中复制它.怎么做?

The most difficult place - creation items with widget in column. I cant reproduce it in Sencha Fiddle. How to do it?

推荐答案

首次登录 Sencha Fiddle 使用 Sencha论坛凭据.之后,复制并粘贴您的代码并保存.保存后获得的更新的URL将是可共享的.请参考 Sencha小提琴上的文档.

First login to 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/编辑器&fiddle/2820

这篇关于过滤网格头extjs 6的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆