PDA

View Full Version : Grid with dynamic combobox editor



ttbgwt
10 Mar 2011, 4:44 AM
For an editorgridpanel, I need to define a column to have a combobox editor. But when the editor is clicked, I need to change the combobox list values depending on the selected row.

ttbgwt
10 Mar 2011, 7:47 AM
I figured it out, I listened on the combo focus event and reloaded the combos store within it.


{
header: 'Input Units',
dataIndex: 'Units',
fixed: true,
hideable: false,
menuDisabled: true,
sortable: false,
width: 70,
editor: new Ext.form.ComboBox({
typeAhead: true,
triggerAction: 'all',
mode: 'local',
listClass: 'x-combo-list-small',
store: new Ext.data.JsonStore({
idProperty: 'Id',
root: 'Data',
fields: ['Id', 'Units'],
sortInfo: {
field: 'Id',
direction: 'ASC'
}
}),
valueField: 'Units',
displayField: 'Units',
listeners:
{
focus: function (combo) {
var id = sm.getSelected().get('Id');

switch (id) {
case 1:
combo.getStore().loadData({
Data: [
{ Id: 1, Units: 'rpm'},
{ Id: 2, Units: 'psig'}
]
});
break;
case 2:
combo.getStore().loadData({
Data: [
{ Id: 1, Units: 'ft-lbs' },
{ Id: 2, Units: 'psia' }
]
});
break;
}
}
}
})
},