2010-07-03 36 views
5

Quiero implementar el siguiente cuadro combinado en ExtJS. La pregunta es, ¿cómo hacer que la tercera opción sea seleccionada por defecto?valor de preseleccionado en el cuadro combinado en extjs

<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> 

Lo que tengo actualmente es:

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' 
}); 

¿Cómo hago la tercera opción (No hay por adelantado) seleccionada por defecto?

Respuesta

10

Es necesario configurar la opción value config para el id del valor predeterminado, por ejemplo .:

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

+0

hola, gracias mucho :) –

Cuestiones relacionadas