PDA

View Full Version : how can I synchronize two combo editors in a grid?



leoebabi
14 Dec 2015, 5:05 AM
I need to edit two columns of my grid using combos as editors, and I need the values shown in the second to be filtered accordingly to the value selected in the first one. There is also the problem that I need to show the "bound" value (i.e. "description") instead of the Id, in the grid cell. I prepared a (very simplified) fiddle to show the problem here

https://fiddle.sencha.com/#fiddle/12hi


Looking at the fiddle, I'd need to select the brand in the first combo and then a model in the second, but I should obviously find only the model from the selected brand in there.

How can I show the descriptive text in the cell?
How can I filter the second combo?

jdkhamba
14 Dec 2015, 5:34 AM
Theoretically, you would need to listen to 'select' event on the brand combo, and in the listener ,you would need to access the models combo and call store.filterBy() on it in order to filter the store so that the result set is displayed correctly.

http://docs.sencha.com/extjs/4.2.0/#!/api/Ext.data.Store-method-filterBy

As for why the combo is not honoring the correct displayField, the cell is disaplaying the value of the combo which happens to be the id. So, you would need a custom renderer for that cell to display the displayfield , probably use getRawValue() on the combo.