Set values in ExtJS Grid
How to set values of components in an ExtJS Grid
HTML
<link rel="stylesheet" href="http://extjs.cachefly.net/ext-4.0.2a/resources/css/ext-all.css">
Check this for more details:<br/>
<a href='http://atechiediary.blogspot.com/2013/06/extjs-grid-update-values-of-elements-in.html'> Detail Blog entry </a>
<br/>
<br/>
JavaScript
Ext.create('Ext.data.Store', {
storeId: 'gridStore',
fields: ['name', 'type', 'control'],
data: {
'items': [{
'name': 'Name'
}, {
'name': 'Age'
}, {
'name': 'Sex'
}]
},
proxy: {
type: 'memory',
reader: {
type: 'json',
root: 'items'
}
}
});
Ext.create('Ext.grid.Panel', {
title: 'Set values in Grid',
store: Ext.data.StoreManager.lookup('gridStore'),
plugins: [
Ext.create('Ext.grid.plugin.CellEditing', {
clicksToEdit: 1
})],
columns: [{
header: 'Field',
dataIndex: 'name'
}, { // Data Types
xtype: 'gridcolumn',
header: 'Type',
dataIndex: 'type',
field: {
xtype: 'combo',
store: new Ext.data.ArrayStore({
fields: ['key', 'value'],
data: [
['Int', 'Int'],
['Double',
'Double'],
['Varchar', 'Varchar']
]
}),
displayField: 'value',
valueField: 'key',
emptyText: 'Select type...',
listeners: {
change: function (field, newValue, oldValue) {
// if type selected is varchar
if (newValue == 'Varchar') {
// get the handler to the grid
var grid = this.up().up();
// get selection model of the grid
var selModel = grid.getSelectionModel();
// set control of the record to text
//NOTE: 'control' here is the value set in the dataIndex property of the Control combobox
selModel.getSelection()[0].set('control', 'TextField');
}
}
}
}
}, { // Control Types
xtype:...