PDA

View Full Version : Bug in Ext.grid.plugin.Editing ?



miroperez
27 Sep 2013, 9:02 AM
We're running into an issue with the cell editing related to I believe a change made in 4.2.x.

In 4.1.x in Ext.grid.plugin.Editing getColumnField() about line 308 the code had:



Ext.apply(field, {
name: columnHeader.dataIndex
});


In 4.2.1 in Ext.grid.plugin.Editing createColumnField() about line 346 the code has:



field = Ext.apply({
name: columnHeader.dataIndex,
column: columnHeader
}, field);


In our code we had to wrap the column.editor in an extension to Ext.grid.CellEditor to handle some cases we had to work around.

When the code runs thru Ext.grid.plugin.CellEditing getEditor() it has this check:


if (editor instanceof Ext.grid.CellEditor) {
editor.floating = true;
}


Because the Ext.apply was reversed from 4.1 to 4.2 the object in field is no longer an instanceof Ext.grid.CellEditor. Before in 4.1 additional props were simply added to the field which was the column.editor before that, but now in 4.2 the field props are being applied to the first object arg, which meansthe field is no longer the same object from column.editor. When I reverse the apply in 4.2.1 to:



field = Ext.apply(field, {
name: columnHeader.dataIndex,
column: columnHeader
});


then it works. It's a subtle change that effects the way we invoke the cell editor.

ettavolt
30 Sep 2013, 3:44 AM
Well, that's definitely not a bug.
If you want ot pass your wrapper, you can always extend it from Ext.grid.CellEditor.

miroperez
30 Sep 2013, 4:26 AM
Well, that's definitely not a bug.
If you want ot pass your wrapper, you can always extend it from Ext.grid.CellEditor.

That's exactly the issue. When we do extend from Ext.grid.CellEditor, after the reversed apply from 4.1 to 4.2 in that code:



field = Ext.apply({
name: columnHeader.dataIndex,
column: columnHeader
}, field);


field is no longer an instanceof Ext.grid.CellEditor. I think all the apply does is copy the props of second to the first object which since the first arg isn't an instanceof Ext.grid.CellEditor it certaintly won't be after the apply right? Hence when I reverse the apply as an override to that method it works. Perhaps there is something different with the apply now but that would seem like a big change from 4.1 to 4.2.

ettavolt
30 Sep 2013, 4:40 AM
Well, you can override getEditor (not getColumnField) to do a proper wrapping in proper place.

miroperez
30 Sep 2013, 6:35 AM
Which getEditor()? The base Ext.grid.plugin.Editing injects the getEditor() into the column via the initFieldAccessors() and the Ext.grid.plugin.CellEditing gets the column editor from this injected method in it's getEditor().

We already have the field wrapped in an extension of Ext.grid.CellEditor and the apply() munges it. It seems like I'd be touching a lot of code for the setup of that column getEditor that's wrapped up in the Editing.js class.

I guess another way of thinking about it is if I directly created an editor with Ext.grid.CellEditor() and passed it into column.editor, the current code would still break right?

ettavolt
30 Sep 2013, 10:27 AM
My bad, I've not taken a precise look on all those delegations.
So, column.getEditor is actually handled by plugin.getColumnField.
Now I don't understand where and when do you wrap a field into an extension of CellEditor? I believe, that it can be done in plugin.getColumnField after default action.