I had a similar problem. The second combobox will load the store and display the values, but when I select the value, it will not actually be selected. I would click on a list item and the combobox value would remain empty.
In my research, it was also suggested that after initialization it is not recommended to change the mapping of the store and the field in the drop-down list, so here was my solution:
- Create a container in the view that combobox will be held to give me a link to add it later.
- Take a copy of the original configuration off combobox (this allows me to explicitly declare my configurator in the view, rather than writing it to the replace function ... in case I want to add other configuration properties later)
- Apply a new store, value Field and displayField to this configuration
- Destroy old combo boxes
- Create a new combobox with a reconfigured
- Using my link from step 1, add a new combo box
View:
items: [{ xtype: 'combobox', name: 'type', allowBlank: false, listeners: [{change: 'onTypeCombo'}], reference: 'typeCombo' }, { // see controller onTypeCombo for reason this container is necessary. xtype: 'container', reference: 'valueComboContainer', items: [{ xtype: 'combobox', name: 'value', allowBlank: false, forceSelection: true, reference: 'valueCombo' }] }, { xtype: 'button', text: 'X', tooltip: 'Remove this filter', handler: 'onDeleteButton' }]
:
replaceValueComboBox: function() { var me = this; var typeComboSelection = me.lookupReference('typeCombo').selection; var valueStore = Ext.getStore(typeComboSelection.get('valueStore')); var config = me.lookupReference('valueCombo').getInitialConfig(); config.store = valueStore; config.valueField = typeComboSelection.get('valueField'); config.displayField = typeComboSelection.get('displayField'); me.lookupReference('valueCombo').destroy(); var vc = Ext.create('Ext.form.field.ComboBox', config); me.lookupReference('valueComboContainer').add(vc); },
Wes grant
source share