martes, 8 de mayo de 2012

ExtJS 4: Actualizar combobox dinamicamente

lo hacemos desde su data store:

var states = Ext.create('Ext.data.Store', {
    fields: ['abbr', 'name'],
    data : [
        {"abbr":"AL", "name":"Alabama"},
        {"abbr":"AK", "name":"Alaska"},
        {"abbr":"AZ", "name":"Arizona"}
        //...
    ]
});

var combo = Ext.create('Ext.form.ComboBox', {
    id:'combiId',
    fieldLabel: 'Choose State',
    store: states,
    queryMode: 'local',
    displayField: 'name',
    valueField: 'abbr',
    renderTo: Ext.getBody()
});

states.removeAll();
states.add({"abbr":"P", "name":"Peru"},{"abbr":"Ec", "name":"Ecuador"});

combo.setValue("lalalala");
console.log(combo.getSubmitData()) //object
console.log(combo.getSubmitValue()) //lalalala
    

http://jsfiddle.net/bXTpt/6/

No hay comentarios:

Publicar un comentario