-
19 Feb 2013 5:03 AM #1
Answered: How do I apply a store to a combobox?
Answered: How do I apply a store to a combobox?
What I want to do is to apply a combobox store to the second combobox according to the selected item in the first combobox. For example if you select Pokemons then the second combobox should load pokemonStore. You change your mind and you select Smurfs, then the second combobox loads the smurfsStore.Code:{ fieldLabel: 'Tip', name: 'SubjectType', allowBlank: false, xtype: 'combo', displayField: 'name', valueField: 'type', typeAhead: true, forceSelection: true, queryMode: 'local', store: subjectTypeStore, listeners: { select: function(a,selected,c){ //console.log(a); var tets = selected[0].data.type; console.log(tets); //console.log(c); } } }, { name: 'SubjectID', allowblank: false, xtype: 'combo', displayField: 'name', valuefield: 'name', typeAhead: true, forceSelection: true, queryMode: 'local' }
What I want to learn is how to apply the store to an existent combobox.
-
Best Answer Posted by scottmartin
See if this will work for you:
Scott.Code:var statesA = Ext.create('Ext.data.Store', { fields: ['abbr', 'name'], data : [ {"abbr":"AL", "name":"Alabama"}, {"abbr":"AK", "name":"Alaska"}, {"abbr":"AZ", "name":"Arizona"} ] }); var statesZ = Ext.create('Ext.data.Store', { fields: ['abbr', 'name'], data : [ {"abbr":"ZL", "name":"ZAlabama"}, {"abbr":"ZK", "name":"ZAlaska"}, {"abbr":"ZZ", "name":"ZArizona"} ] }); var comboA = Ext.create('Ext.form.ComboBox', { fieldLabel: 'Choose State', store: statesA, queryMode: 'local', displayField: 'name', valueField: 'abbr', renderTo: Ext.getBody(), listeners: { select: function(combo) { comboZ.bindStore(statesZ); } } }); var comboZ = Ext.create('Ext.form.ComboBox', { fieldLabel: 'Choose State', store: null, queryMode: 'local', displayField: 'name', valueField: 'abbr', renderTo: Ext.getBody() });
-
19 Feb 2013 11:59 AM #2Sencha - Support Team
- Join Date
- Jul 2010
- Location
- Houston, Tx
- Posts
- 7,186
- Vote Rating
- 194
- Answers
- 433
See if this will work for you:
Scott.Code:var statesA = Ext.create('Ext.data.Store', { fields: ['abbr', 'name'], data : [ {"abbr":"AL", "name":"Alabama"}, {"abbr":"AK", "name":"Alaska"}, {"abbr":"AZ", "name":"Arizona"} ] }); var statesZ = Ext.create('Ext.data.Store', { fields: ['abbr', 'name'], data : [ {"abbr":"ZL", "name":"ZAlabama"}, {"abbr":"ZK", "name":"ZAlaska"}, {"abbr":"ZZ", "name":"ZArizona"} ] }); var comboA = Ext.create('Ext.form.ComboBox', { fieldLabel: 'Choose State', store: statesA, queryMode: 'local', displayField: 'name', valueField: 'abbr', renderTo: Ext.getBody(), listeners: { select: function(combo) { comboZ.bindStore(statesZ); } } }); var comboZ = Ext.create('Ext.form.ComboBox', { fieldLabel: 'Choose State', store: null, queryMode: 'local', displayField: 'name', valueField: 'abbr', renderTo: Ext.getBody() });


Reply With Quote