martes, 8 de mayo de 2012

ExtJs 4: Cambiar Store de un combobox

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

var paises = Ext.create('Ext.data.Store', {
    fields: ['abbr', 'name'],
    data : [
        {"abbr":"AL", "name":"alemani"},
        {"abbr":"RU", "name":"Rusia"},
        {"abbr":"JA", "name":"Japon"}
        //...
    ]
});


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.store = paises; //Cambio el estore rck

No hay comentarios:

Publicar un comentario