1
{
    fieldLabel: 'Tip',
    name: 'SubjectType',
    allowBlank: false,
    xtype: 'combo',
    displayField: 'name',
    valueField: 'type',
    typeAhead: true,
    forceSelection: true,
    queryMode: 'local',
    store: subjectTypeStore,
    listeners: {
        select: function(a,selected,c){
            //console.log(a);
            var tets = selected[0].data.type;
            console.log(tets);
            //console.log(c);
        }
    }
},
{
    name: 'SubjectID',
    allowblank: false,
    xtype: 'combo',
    displayField: 'name',
    valuefield: 'name',
    typeAhead: true,
    forceSelection: true,
    queryMode: 'local'
}

What I want to do is to apply a combobox store to the second combobox according to the selected item in the first combobox. For example if you select Pokemons then the second combobox should load pokemonStore. You change your mind and you select Smurfs, then the second combobox loads the smurfsStore.

What I want to learn is how to apply the store to an existent combobox.

ilhan
  • 8,700
  • 35
  • 117
  • 201

1 Answers1

4

Here's a simple example JSFiddle

select: function(checkbox,records) {
      comp.clearValue();
      comp.bindStore(Ext.StoreMgr.lookup(records[0].data.store));
      // you can change the value field if needed
      comp.displayField = 'petname'; 
      // you can change the display field if needed
      comp.valueField = 'id'; 
      // you can change the display template if needed
      comp.displayTpl = new Ext.XTemplate(
          '<tpl for=".">' +
              '{[typeof values === "string" ? values : values["' + comp.displayField + '"]]}' +
              '<tpl if="xindex < xcount">' + comp.delimiter + '</tpl>' +
          '</tpl>'
      );
      comp.picker = null;
 }
sra
  • 23,820
  • 7
  • 55
  • 89
  • The JSFiddle example mentioned above is not working - seems external resources are added wrongly. Find the updated example with valid ext resorces & frmwrk which works perfectly. http://jsfiddle.net/TpdeC/16/ – Srikanth Aug 06 '14 at 06:03
  • `bindStore` is the important call here - rather than `reconfigure` which everything else uses – JonnyRaa Apr 02 '15 at 11:20