PDA

View Full Version : Loading subset of json into editable combobox in the Grid



tharahan
21 Jan 2013, 8:52 AM
Hi

I am building a grid based on JSON data which is based on the following

var subAccountStore = new Ext.data.JsonStore({
autoLoad: true,
proxy: {
type:'ajax',
url : '/opUI/json/subaccount.action?name="ABC"'
},
fields: ['accountName', 'accountNumber','accountNumbers', 'quantity']

});

and the sample JSON is

[{"accountName":"'ABC'","accountNumber":"123456","quantity":100,"accountNumbers":['12345A','12345B','12345C']},{"accountName":"'XYZ'","accountNumber":"999999","quantity":100,"accountNumbers":['99999A','99999B','99999C']}]

Now I am trying to build grid with editable combo box as one of column

So my code snippet is
columns: [
{
text : 'Account Name',
width : 60,
flex : 3,
sortable : true,
dataIndex: 'accountName'
},
{
text : 'Account Number',
flex : 2,
sortable : false,
dataIndex: ???,
editor: new Ext.form.field.ComboBox({
typeAhead: true,
triggerAction: 'all',
selectOnTab: true,
store: ???,
lazyRender: true,
listClass: 'x-combo-list-small'



})
},
{
text : 'Quantity',
flex : 2,
sortable : true,
dataIndex: 'quantity',
align : 'right',
editor: {
xtype: 'numberfield',
allowBlank: false,
minValue: 0,
maxValue: 100000
}
}
]


I am not sure how to make each row shows combobox of it's accountNumbers.

I would really appreciate if some one can put me in the right direction.

Thanks
Tharahan

mitchellsimoens
23 Jan 2013, 10:40 AM
By default the combobox you would need to set a store with it's own data, to get it from the response from the grid, you would need to extend the editing plugin and set the data from the record being edited onto the combobox's store.

tharahan
29 Jan 2013, 8:46 AM
Thanks the response.

Can you give me an example for extending the editing plugin?

Thanks
Tharahan