PDA

View Full Version : Cascading combo - Store.filterby not working first time



SurajSrinivasan
15 Feb 2010, 8:35 AM
I have 2 combo boxes (c1 and c2). Selecting a value in c1, should filter the drop down list in c2. This does not happen the first time. However, if I click once on c2 and view the c2 drop down and then select a value in c1, then c2 gets filtered.

Here is my code relevant for this issue:
var c1 = new Ext.form.ComboBox({
fieldLabel: comboLabel,
id: comboId,
name: comboId,
width:250,
typeAhead: true,
triggerAction: 'all',
lazyRender: true,
store: c1Store,
displayField: comboDisplay,
triggerAction: 'all',
emptyText:'Select ' + comboLabel,
valueNotFoundText: valNotFound,
selectOnFocus:true,
mode: 'local',
valueField: comboValue,
allowBlank:false
});

c1.on('select', function fn (cb, record, index) {
c2Store.filterBy(function fn (rec, id) {
var curWf = rec.get('SYSCODE');
for (x in wfcList) {
if (wfcList[x] == curWf) {
return true;
}
}
return false;
});
})

c1Store and c2Store are already loaded when the code is executed.

However, this code only filters c2, after I click once on it. Am I missing anything here. I also tried a c2.doLayout and tried using Ext.getCmp().getStore.filterBy instead of c2Store.filterBy, but still the issue persists.

fay
15 Feb 2010, 8:44 AM
Post your code for c2, and please use CODE tags

SurajSrinivasan
15 Feb 2010, 8:48 AM
Here is the code for c2. Same as that of c1.


var c2 = new Ext.form.ComboBox({
fieldLabel: comboLabel1,
id: comboId1,
name: comboId1,
width:250,
typeAhead: true,
triggerAction: 'all',
lazyRender: true,
store: c2Store,
displayField: comboDisplay1,
triggerAction: 'all',
emptyText:'Select ' + comboLabel1,
valueNotFoundText: valNotFound1,
selectOnFocus:true,
mode: 'local',
valueField: comboValue1,
allowBlank:false
});


and comboValue1 = 'SYSCODE'

fay
15 Feb 2010, 9:02 AM
Try adding


lastQuery:''

to the config for c2.

SurajSrinivasan
16 Feb 2010, 1:08 AM
Thanks fay. That makes it work.

SurajSrinivasan
16 Feb 2010, 1:33 AM
Thanks fay. That makes it work.

rsgjenny09
18 Jun 2010, 7:17 AM
I creates two combo boxes, the first one's selected value filters the second one's store.
But when I type select the first combo, then tab through to the second combo, type in some letter, store shows all the data for the second combo, no filter looks applied. This only happens on the first time also.

Any one has same experience?

Thanks