View Full Version : Cellediting startEdit

19 Jul 2012, 12:30 AM
Hey guys,

Just a quick question on the startEdit function in the cellediting plugin.
startEdit (http://docs.sencha.com/ext-js/4-0/#%21/api/Ext.grid.plugin.CellEditing-method-startEdit)( Ext.data.Model (http://docs.sencha.com/ext-js/4-0/#%21/api/Ext.data.Model) record, Ext.data.Model (http://docs.sencha.com/ext-js/4-0/#%21/api/Ext.data.Model) columnHeader )

What is the columnHeader? I have a function that creates a new row and I want it to start editing the new row as soon as it is created.

insertNew : function(grid, rowIndex, colIndex) {
var me = this,
store = grid.getStore();

var r = Ext.create('personModell', {
name : null,
age : null,
sex : null

store.insert(rowIndex, r);
grid.editingPlugin.startEdit(r, ?);

I would like for it to start editing in the name column.


19 Jul 2012, 12:50 AM
you can simply put the column index there!

19 Jul 2012, 3:01 AM
Hi Farish,

That doesn't seem to be working. Also would it be possible to reference the column here by name rather than index?


19 Jul 2012, 3:05 AM
yes that would also work. I use the index in the rowediting plugin and what it does is to focus the cursor to that column (for which usually I use 1 for the 1st column).

19 Jul 2012, 3:15 AM
For some reason this is not working in my grid. When I try and do it through firebug it returns false.

19 Jul 2012, 3:16 AM
you can try debugging using Firebug and see where things go wrong in the sources.

19 Jul 2012, 3:17 AM
This is what I put into firebug:

javascript: var r = Ext.getCmp("gridpanel-1097").getStore().getAt(0); Ext.getCmp("gridpanel-1097").editingPlugin.startEdit(r,1);

That doesn't work. I have to do some debugging alright. Thanks for the help.

19 Jul 2012, 3:23 AM

is this returning your plugin?

19 Jul 2012, 3:45 AM
Yes it is returing "Ext.grid.plugin.CellEditing".

I can't see what the problem is? It keeps returning false everytime I try to startEdit.

Also should note that I am using EXT JS 4.0.7

19 Jul 2012, 3:49 AM
Okay I think it is a 4.0.7 bug.


I used startEditByPosition and it works.

Thanks Farish for all the help.

19 Jul 2012, 3:52 AM
hmmm. it works fine for the rowediting plugin. I am also using 4.0.7. probably only happens with cellediting. thanks for letting me know too. might save me some time in the future if i run across it :)

19 Jul 2012, 4:07 AM
to start editing at the 'name' column you have to take a look at your grid.
if your grid columns are exact in the same order as your record, then your code looks like:

grid.editingPlugin.startEdit(r, 0);

but if you do have something like this:

columns :[
{ text:'id', dataIndex:'id', hidden:true },
{ text:'age', dataIndex:'age',editor:/*...*/},
{ text:'name', dataIndex:'age',editor:/*...*/},
{ text:'sex', dataIndex:'age',editor:/*...*/},

then your code looks like this:

// start editor on age
grid.editingPlugin.startEdit(r, 1);
// start editor on name
grid.editingPlugin.startEdit(r, 2);
// start editor on sex
grid.editingPlugin.startEdit(r, 3);

19 Jul 2012, 6:12 AM
Yes I took this into account and it's all working now.

Thanks very much