2013-02-18 72 views
2

我已经添加了默认的远程过滤器到网格'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 
    }) 
}); 

回答

2

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

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

如果不处理它,你也可以通过编程设置的过滤器(而不是仅仅使用配置)。详见this answer

+0

我以为我也试过,无论如何它现在工作,谢谢。 ExtJs是非常棒的工具,然而,有时候找到你所需要的东西需要很长时间,而且它的文档并不令人满意并且用户友好。 – efirat 2013-02-20 13:11:56