Ext网格过滤默认过滤器激活加载

时间:2013-02-18 10:32:26

标签: extjs filter grid extjs4

我为列'hiddenFlag'添加了默认远程过滤器到网格,但是在第一次加载时它没有激活。单击列标题菜单时,过滤器似乎处于活动状态,但现在记录是合适的。我应该停用并再次激活它。

filter seems to be active, however it is not!

怎样,我可以将它配置为第一次加载也是活动的?

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
    })
});

1 个答案:

答案 0 :(得分:2)

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

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

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