-
6 Jul 2012 8:41 AM #1
Answered: Add blank entry to combobox
Answered: Add blank entry to combobox
Hello.
I have a combobox with data.Store.
How i can add an empty option to the combobox?
-
Best Answer Posted by friend
A simple solution might be to use the combo's emptyText config option.
If that doesn't work for you, you could always use the store's load event to insert a blank record..
-
6 Jul 2012 8:47 AM #2
A simple solution might be to use the combo's emptyText config option.
If that doesn't work for you, you could always use the store's load event to insert a blank record..Last edited by friend; 6 Jul 2012 at 8:47 AM. Reason: clarity
-
6 Jul 2012 9:50 AM #3Sencha - Support Team
- Join Date
- Jul 2010
- Location
- Houston, Tx
- Posts
- 7,186
- Vote Rating
- 194
- Answers
- 433
Something like this should work:
Scott.Code:// The data store containing the list of states var states = Ext.create('Ext.data.Store', { fields: ['abbr', 'name'], data : [ {"abbr":"AL", "name":"Alabama"}, {"abbr":"AK", "name":"Alaska"}, {"abbr":"AZ", "name":"Arizona"} ], listeners: { load: function(store){ var rec = { abbr: '', name: '-' }; store.insert(0,rec); } } }); // 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() });
-
6 Jul 2012 10:44 AM #4
Thank you! It works great.
Code:Ext.define('AM.store.Beers', { extend: 'Ext.data.Store', model: 'AM.model.Beer', listeners: { load: function(store) { var model = Ext.create('AM.model.Beer', { id: '', number: 'Not Set' }); store.autoSync = false; store.insert(0,model); } } });
-
4 Jan 2013 4:00 AM #5
Great Work.. Its Working Absolutely fine
Ravi Maroju


Reply With Quote