PDA

View Full Version : Make some cell not editable in same column for editable grid



yogesh.dabhi91
20 Jun 2012, 5:23 AM
Hi All,

I have one column with numeric field for cellediting grid.
I want to make some cell to non editable for that column.

Is it possible.
Please reply as soon as possible.

Thanks & Regards
Yogesh

scottmartin
20 Jun 2012, 12:01 PM
See if this will help:



Ext.create('Ext.data.Store', {
storeId:'simpsonsStore',
fields:['name', 'email', 'change'],
data:{'items':[
{ 'name': 'Lisa', "email":"lisa@simpsons.com", "change":100 },
{ 'name': 'Bart', "email":"bart@simpsons.com", "change":-20 },
{ 'name': 'Homer', "email":"home@simpsons.com", "change":23 },
{ 'name': 'Marge', "email":"marge@simpsons.com", "change":-11 }
]},
proxy: {
type: 'memory',
reader: {
type: 'json',
root: 'items'
}
}
});

var cellEditing = Ext.create('Ext.grid.plugin.CellEditing', {
clicksToEdit: 1,
listeners: {
beforeedit: function(edit,opt){
if (edit.value === 'Bart') { // do not edit bart!
return false;
}
}
}

});

Ext.create('Ext.grid.Panel', {
title: 'Simpsons',
store: Ext.data.StoreManager.lookup('simpsonsStore'),
columns: [
{ header: 'Name', dataIndex: 'name', editor: { xtype: 'textfield' } },
{ header: 'Email', dataIndex: 'email', flex: 1 },
{ header: 'Change', dataIndex: 'change', tdCls: 'x-change-cell' }
],
height: 200,
width: 400,
plugins: [cellEditing],
renderTo: Ext.getBody()
});


Scott.