-
26 Jun 2012 1:57 AM #1
Answered: combo adding items
Answered: combo adding items
How do I add items to a combofield dynamicly?
I cant find any sample that does not invlove a store.
If this the case how do I create an empty store and add model instance to it so that the combo will show these items?
-
Best Answer Posted by scottmartin
You can use a simple array store and populate the array as needed
use store.loadData(data) to populate the store
Regards,Code:var data = [ {"abbr":"AL", "name":"Alabama"}, {"abbr":"AK", "name":"Alaska"}, {"abbr":"AZ", "name":"Arizona"} ]; // The data store containing the list of states var states = Ext.create('Ext.data.Store', { fields: ['abbr', 'name'], data : [ ] }); // Create the combo box, attached to the states data store Ext.create('Ext.form.ComboBox', { fieldLabel: 'Choose State', store: states, queryMode: 'local', displayField: 'name', valueField: 'abbr', renderTo: Ext.getBody() }); states.loadData(data);
Scott.
-
26 Jun 2012 9:23 AM #2Sencha - Support Team
- Join Date
- Jul 2010
- Location
- Houston, Tx
- Posts
- 7,186
- Vote Rating
- 194
- Answers
- 433
You can use a simple array store and populate the array as needed
use store.loadData(data) to populate the store
Regards,Code:var data = [ {"abbr":"AL", "name":"Alabama"}, {"abbr":"AK", "name":"Alaska"}, {"abbr":"AZ", "name":"Arizona"} ]; // The data store containing the list of states var states = Ext.create('Ext.data.Store', { fields: ['abbr', 'name'], data : [ ] }); // Create the combo box, attached to the states data store Ext.create('Ext.form.ComboBox', { fieldLabel: 'Choose State', store: states, queryMode: 'local', displayField: 'name', valueField: 'abbr', renderTo: Ext.getBody() }); states.loadData(data);
Scott.
-
26 Jun 2012 8:56 PM #3


Reply With Quote