PDA

View Full Version : ComboBox in EditorGrid will not filter its contents on first edit



Springvar
18 Mar 2011, 1:55 AM
I've got an EditorGrid with a ComboBox set up against a JsonStore.

Depending on the selected row I want to filter the contents of the ComboBox.

So I've tried this:



myGrid.on('beforeedit',function(event){
var currentProjectGroup = event.record.get('projectGroupId');
Ext.StoreMgr.get('myProjects').filter('projectGroupId',currentProjectGroup,false,false,true);
});

myGrid.on('afteredit',function(event){

Ext.StoreMgr.get('myProjects').clearFilter();
});


And it works fine from the second edit. On the first edit, the ComboBox will return all projects, and not filter them. I'm guessing it's caused by the ComboBox not beeing created until after the first beforeedit-event, but I've not found a way to force the newly created ComboBox to respect my filter.

Any ideas?

The ComboBox is set up like this


editor: {
xtype: 'combo',
store: 'myProjects',
name: 'projectSelector',
displayField: 'displayName',
valueField: 'id',
clearFilterOnReset: false,
lazyInit: false,
triggerAction: 'all',
mode: 'local',
lazyRender: true
}


The store more or less like this:


myProjects = Ext.extend(Ext.data.JsonStore, {
constructor: function(cfg) {
cfg = cfg || {};
myProjects.superclass.constructor.call(this, Ext.apply({
storeId: 'myProjects',
root: 'projects',
autoLoad: true,
messageProperty: 'message',
api: {...},
fields: [
{
name: 'id',
type: 'int'
},
{
name: 'displayName',
type: 'string'
},
{
name: 'projectGroupId'
}
]
}, cfg));
}
});

danaxelrod
18 Aug 2011, 12:20 AM
Good question. I have the same problem.... Has anyone figured this out?