views:

74

answers:

1

Hi all i want to inplemnt this combobox in extjs main thing is how to make "selected" value 3

<select name="meter_payment_option" onChange="smart_meter(this.value)"> 
<option value ="1">All Up-Front</option> 
<option value ="2">Reduced Up-Front</option> 
<option value ="3" selected="selected">No Up-Front</option> 
</select> 

till now what i have done is

var meter_payment_option_values  = new Ext.data.SimpleStore({
                                                                fields: ['id', 'value'],
                                                                data : [['1','All Up-Front'],['2','Reduced Up-Front'],['3','No Up-Front']]
                                                        }); 

var smart_meter_term = new Ext.form.ComboBox({

                      ` name:'smart_meter_term' ,
                      editable: false,
                      typeAhead: false, 
                      allowblank:false , 
                      triggerAction: 'all',
                      hiddenName: 'my_dropdown',
                      fieldLabel:'SmartM.T',
                      store:meter_payment_option_values,
                      displayField:'value',
                      valueField:'id',
                      mode:'local'
                    });

` The main problem is how do i make it "3rd option= ['3','No Up-Front'] " defaulty selected

+1  A: 

You need to set the value config option to the id of the default value, e.g.:

var smart_meter_term = new Ext.form.ComboBox({
                  name:'smart_meter_term' ,
                  editable: false,
                  typeAhead: false, 
                  allowblank:false , 
                  triggerAction: 'all',
                  hiddenName: 'my_dropdown',
                  fieldLabel:'SmartM.T',
                  store:meter_payment_option_values,
                  displayField:'value',
                  valueField:'id',
                  mode:'local',
                  // default value is 3 (No Up-Front)
                  value: 3
                });

http://www.sencha.com/deploy/dev/docs/index.html?class=Ext.form.ComboBox

tomit
hi there , thankyou very much :)
Extjs Commander