Vítor Nóbrega Vítor Nóbrega - 1 month ago 5
Javascript Question

How define differents stores for each cell combobox editor in a grid?

I need to implement a grid, using extjs 4.2.1. This grid will have cellEditing plugin and in the columns I will have many textfields and comboboxes.

My problem is for a particular case. I have a column for countries (by example). Columns editor will be combobox with a store with countries.
The next combobox will be cities of selected country at the same row index. When I define that store, this column will stay with the same store and I don't know this.

In row 0, I select USA and I have to load US cities in the next combo.
In row 1, I select UK country and I have to load UK cities but if go back to row 0 and select US cities I want to see USA cities and not UK cities.

How I can define differentes stores for each combo cell?

Answer

You must define your store once like


Ext.define('MyApp.city.Store',{
   extend:'Ext.data.Store',
   //all properties which you need
});

and you should create instance of it in for city cell like


cityStore = Ext.create('MyApp.city.Store');