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

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

问题描述

我已将默认远程过滤器添加到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天全站免登陆