PDA

View Full Version : EditorGridPanel with Combo populated from nested JSON



John Sourcer
22 Feb 2010, 12:15 AM
Hi All,

Searched and tried several solutions to no avail.

I have an EditorGridPanel populated from JSON below:



{
"units": [
{
"region": "A",
"devices": [
{
"devType": "type1"
}
]
},
{
"region": "B",
"devices": [
{
"devType": "type1"
},
{
"devType": "type2"
},
{
"devType": "type3"
}
]
}
]
}


I want to make the 'devices' column a combo populated from the nested JSON. I've tried repopulating a set store on the column renderer but failed quite badly there. Also, tried doing it via a listener on the column model. Fail. :(

Any directional bump will help.

danellison
22 Feb 2010, 11:41 AM
The way I have done this in the past is like this:



var grid = new Ext.gid.EditorGridPanel({
....
colModel: [{
....
{
header: 'Whatever',
dataIndex: 'devType',
width: 175,
editor: new Ext.form.ComboBox({
typeAhead: true,
mode: 'local',
forceSelection: true,
displayField: 'devType',
triggerAction: 'all',
store: new Ext.data.JsonStore({
fields: ['devType],
data: json.units.devices
})
})
}
}]
});


Give it a go. Should be workable.
Dan