View Full Version : Linked combos in grid

17 Jan 2011, 5:24 PM
I've been struggling to figure out how to get this done properly. I really just want the obvious linked combos in a grid.

Please see this thread, which was pretty helpful:

So now I've got:


IDB.selectbox.SelectBox = Ext.extend(Ext.ux.form.SelectBox, {
Ext.reg('IDB.selectbox.SelectBox', IDB.selectbox.SelectBox);
IDB.selectbox.Site = Ext.extend(IDB.selectbox.SelectBox, {
mode : 'remote',
fieldLabel: 'Site',
name: 'site_code',
store: Ext.StoreMgr.get('storeSites'),
valueField: 'site_code',
displayField: 'site_code',
initComponent : function() {
Ext.reg('IDB.selectbox.Site', IDB.selectbox.Site);

Snippet from my grid/form container object initComponent:

this.getGridPanel().on('beforeedit', function(e) {
Ext.StoreMgr.get('storeSites').filter('site_code', 'LAX010');

Problem: The first time I click a selectbox to edit, I see the unfiltered list. Any subsequent edits show the filtered version.

Any ideas?


18 Jan 2011, 12:45 AM
Configure the ComboBox (or SelectBox) with:

triggerAction: 'all',
lastQuery: ''
(otherwise it will clear the existing filter)

18 Jan 2011, 8:28 AM
I'll give that a shot right now. Since it was already working after the first click, if these parameters help I won't know why.

18 Jan 2011, 8:31 AM
Well I guess I shouldn't be surprised - it works fine now.

Can you give me ten words on why it didn't work before, and what this changed?

18 Jan 2011, 8:37 AM
Not in ten words...

A mode:'local' ComboBox uses filtering to filter the store when something is typed.
You can disable this by setting triggerAction:'all', but that still makes the store clear the filter the first time it is used.
By specifying lastQuery:'' you make the ComboBox believe it already cleared the filter (it checks to see if it needs to filter by comparing the current value with lastQuery - and in case of triggerAction:'all' the current value is set to allQuery - which is '' by default).

18 Jan 2011, 8:43 AM
That still doesn't explain why it would filter properly after the second click. There's a piece of the puzzle I feel I'm missing.

18 Jan 2011, 11:44 PM
Your filter action happens before the combobox is shown, so assume the store is properly filtered when you click the trigger.
SelectBox already uses triggerAction:'all', so the first time you click on the trigger if will check if the current query (= allQuery = '') is equal to lastQuery (= undefined). It isn't so it clears the filter and stores the current query in lastQuery.
The next time you press on the trigger is checks the current query (= allQuery = '') is equal to lastQuery (= ''). It is, so it doesn't clear the filter.