-
3 Feb 2011 3:38 AM #1
Default value of combobox
Default value of combobox
I have local var (Array list) which has three key, value pairs.
I want the second value to be displayed in the combo box and its key as default.
Code:Ext.onReady(function(){ var group = [['brand', 'Product'],['site', 'Location'],['environment', 'Environment']]; Ext.QuickTips.init(); var store = new Ext.data.ArrayStore({ fields: ['abbr', 'group'], data : group }); var combo = new Ext.form.ComboBox({ store: store, displayField:'group', typeAhead: true, mode: 'local', forceSelection: true, triggerAction: 'all', emptyText:'Location', //So the 'Location' which is second value is to be displayed. And its key 'site' selectOnFocus:true, applyTo: 'local-states' }); combo.selectByValue('site', true); });
-
3 Feb 2011 4:41 AM #2
Add a valueField config param?
var combo = new Ext.form.ComboBox({
//... As before
valueField: 'abbr'
});
combo.selectByValue('site', true);
-
3 Feb 2011 4:45 AM #3Sencha - Community Support Team
- Join Date
- Mar 2007
- Location
- The Netherlands
- Posts
- 24,251
- Vote Rating
- 40
Yes, you should specify valueField:'abbr', but also replace emptyText:'Location' with value:'site'.
Similar Threads
-
How to set a default value for a comboBox ?
By rvillane in forum Ext 2.x: Help & DiscussionReplies: 2Last Post: 7 Oct 2008, 12:39 PM -
[Fix] Combobox Default Value
By kilrae in forum Ext 1.x: BugsReplies: 3Last Post: 29 Sep 2008, 11:28 PM -
Combobox with default value
By bowa in forum Ext 2.x: Help & DiscussionReplies: 1Last Post: 28 Feb 2008, 4:04 PM -
Combobox - default value
By mnugter in forum Ext 2.x: Help & DiscussionReplies: 4Last Post: 12 Mar 2007, 11:56 PM


Reply With Quote