2013-02-18 69 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