问题
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
})
});
回答1:
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.
来源:https://stackoverflow.com/questions/14934186/ext-grid-filtering-default-filter-activation-on-loading