外网过滤默认过滤激活加载 [英] Ext grid filtering default filter activation on loading

查看:133
本文介绍了外网过滤默认过滤激活加载的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经为hiddenFlag列添加了默认的远程过滤器,但是它在首次加载时不起作用。当我单击列标题菜单时,过滤器似乎是活动的,但记录现在是适当的。我应该停用并再次激活它。

I have added default remote filter to grid for column 'hiddenFlag', however it is not active on first loading. When I click column header menu, filter seem to be active however records is now appropriate. I should deactivate and activate it again.

如何将其配置为在第一次加载时有效?

how, I can configure it to be active for the first load also?

Ext.define('Ext.migration.CommentGrid', {
    extend: 'Ext.grid.Panel',
    alias: 'widget.commentgrid',            
    xtype: 'grid',
    initComponent: function(){
        filePath = "";
        this.filters = {
                ftype: 'filters',
                encode: false, // json encode the filter query
                local: false, //only filter locally
                filters: [{
                    type: 'numeric',
                    dataIndex: 'id'
                }, {
                    type: 'boolean',
                    dataIndex: 'publishableFlag'
                }, {
                    type: 'boolean',
                    dataIndex: 'hiddenFlag',
                    value:0,
                    active:true
                }
                ]
            };        
        Ext.apply(this, {
            iconCls: 'icon-grid',
            features: [this.filters],
            selType: 'rowmodel',
            columns: [
                {
                    text: 'ID',
                    hideable: false,
                    dataIndex: 'id'
                },
                {
                    xtype: 'checkcolumn', 
                    text: 'Yayınlandı mı?',
                    dataIndex: 'publishableFlag'
                },
                {
                    xtype: 'checkcolumn', 
                    text: 'Gizle',
                    dataIndex: 'hiddenFlag',
                    filter: {
                        value:0,
                        active:true
                    }
                }
            ]
        });
        this.callParent();
    },
    listeners:{
        'afterrender': function(a,b,c){
            //Ext.getCmp()
            console.log("after render", this);

        }
    },
    bbar: Ext.create('Ext.PagingToolbar', {
        store: commentStore,
        displayInfo: true
    })
});


推荐答案

确保过滤器在 afterrender 事件,例如:

Ensure that the filters are created in the afterrender event, e.g.:

listeners:{
    'afterrender': function(grid){
        grid.filters.createFilters();
    }
},

如果没有处理它,你也可以以编程方式设置过滤器(而不仅仅是使用配置)。如此答案所述。

If that doesn't handle it you can also programmatically set the filters (instead of just using a config). As covered in this answer.

这篇关于外网过滤默认过滤激活加载的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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