【问题标题】:Ext grid filtering default filter activation on loading加载时外部网格过滤默认过滤器激活
【发布时间】:2013-02-20 08:08:22
【问题描述】:

我已将默认远程过滤器添加到“hiddenFlag”列的网格中,但它在首次加载时不活动。当我单击列标题菜单时,过滤器似乎处于活动状态,但现在记录是合适的。我应该停用并再次激活它。

如何,我可以将其配置为在第一次加载时也处于活动状态?

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

【问题讨论】:

    标签: extjs filter grid extjs4


    【解决方案1】:

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

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

    如果这不能解决问题,您还可以通过编程方式设置过滤器(而不仅仅是使用配置)。如this answer 所述。

    【讨论】:

    • 我想我也试试这个,反正它现在工作了,谢谢。 ExtJs 是很棒的工具,但是,有时要找到您需要的东西需要很长时间,而且它的文档并不令人满意且用户友好。
    猜你喜欢
    • 2011-08-25
    • 2018-01-22
    • 2021-01-31
    • 2016-02-13
    • 2017-08-11
    • 2012-10-15
    • 2012-05-03
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多