PDA

View Full Version : [ CELLEDITING ] multiple filed type



Tchinkatchuk
18 Oct 2012, 5:49 AM
Hi all,

I have a grid populating via a store.
Cell Editing Plugin works fine but edition i always done via a textfield.

But I would like to specifiy the field to be a checkbox for the row x, a combo for the row y ...

Does anyone has a clue how to manage this ?

Thanks in advance for any idea.

vietits
18 Oct 2012, 6:06 AM
You can use Ext.grid.column.Column.getEditor() (http://docs.sencha.com/ext-js/4-1/#!/api/Ext.grid.column.Column-method-getEditor). Example:


var grid = Ext.create('Ext.grid.Panel', {
...
plugins: [{
ptype: 'cellediting',
listeners: {
beforeedit: function(editor, context){
editor.editors.removeAtKey(context.column.getItemId());
}
}
}],
columns: {
items: [{
text : 'Company',
getEditor: function(record, defaultField){
return record.get('field') > 0 ? 'textfield' : 'checkbox';
},

Tchinkatchuk
18 Oct 2012, 11:11 AM
You're the man !!

I'll try that as soon as possible. Great !

Tchinkatchuk
23 Oct 2012, 2:22 AM
This works and not ^^

The first time i click on a field, the correct field (combo, textarea, ...) is shown.
But after thaht, all the filed will be the same for the oher cell on the same column even if the same code is launch.

Strange behaviour. I think the plugin call the getEditor but do not change if the type is different.

vietits
23 Oct 2012, 4:54 AM
Do you try the code I have updated. With this code, the existing editor will be delete in the beforeedit event the the editor will be re-created.