PDA

View Full Version : [OPEN-EXTJSIV-1789][4.0.0] Cannot edit cells after grid reconfigure



arthurakay
27 Apr 2011, 9:30 AM
After reconfiguring a grid, you can no longer edit the cells.

Error: "column.getEditor is not a function" line 79126 ext-all-debug.js

Example:

Ext.getBody().update('');
Ext.define('Test', {
extend: 'Ext.data.Model',
fields: [ {name: 'name', type: 'string'} ]
});
var store = new Ext.data.Store({
model: 'Test',
data: [
{ name: '123' }
]
});
var columns = [{
header: 'Name',
dataIndex: 'name',
field: { allowBlank: false }
}];
var grid = new Ext.grid.Panel({
renderTo: document.body,
store: store,
height: 300,
width: 300,
columns: columns,
plugins: [
Ext.create('Ext.grid.plugin.CellEditing', { clicksToEdit: 1 })
]
});
grid.reconfigure(store, columns);

The error won't occur until you attempt to click on a cell.

azuroff
27 Apr 2011, 9:37 AM
Uh-oh...

I was planning to start working on the cell editing functionality today. :((

rafterr
27 Apr 2011, 9:01 PM
I know this thread is a bit stale, but any help would be much appreciated:

Is there a work around to this problem? It looks like the editor plugin doesn't reconfigure after you change the columns and store via grid.reconfigure.

I'm working on a form that changes an editor grids columns depending on what the user selects, columns and store are both server generated.

rafterr
11 May 2011, 8:53 PM
Anyone got any ideas?

FinkUndPartner
25 May 2011, 12:28 AM
This solution works for me:



var myCellEditor = new Ext.grid.plugin.CellEditing({
clicksToEdit: 1
});

var myGrid = new Ext.grid.Panel({
....,
plugins: [myCellEditor]
});

var myStore = new Ext.data.JsonStore({
....
});
myStore.on('load', storeLoaded);

function storeLoaded(r, options, success){
...
myGrid.reconfigure(null, myStore.proxy.reader.fields);
myCellEditor.init(myGrid); // Fix CellEditor!!!
...
}


Greetings
Michael Küpper

rafterr
25 May 2011, 3:07 PM
This solution works for me:



var myCellEditor = new Ext.grid.plugin.CellEditing({
clicksToEdit: 1
});

var myGrid = new Ext.grid.Panel({
....,
plugins: [myCellEditor]
});

var myStore = new Ext.data.JsonStore({
....
});
myStore.on('load', storeLoaded);

function storeLoaded(r, options, success){
...
myGrid.reconfigure(null, myStore.proxy.reader.fields);
myCellEditor.init(myGrid); // Fix CellEditor!!!
...
}


Greetings
Michael Küpper

Thank you so much Michael! It works like a charm :-)

cellEditing.init(grid);

sheep-allegro
15 Nov 2011, 1:45 AM
I have a similar problem, but the workaround posted here didn't work. After some poking around, I discovered that I need to re-setEditor on all the columns to make it work again. I added something like this to my GridPanel:



listeners: {
reconfigure: function (grid) {
Ext.each(grid.columns, function (column) {
column.setEditor({ ... });
});
}
},


This works for me, because all my columns use the same editor. For general case you would probably need to save the editor config on a side and use that.

I still have this problem in 4.0.7.

Sorry, after some more testing I concluded that the above workaround doesn't really work.

r0ro
15 Feb 2012, 10:04 AM
Hi,

I'm having the same kind of issue when I call reconfigure with a new store.
None of the proposed workaround seems to work for me with Ext 4.0.7.

plinyar
23 Feb 2012, 10:18 PM
Does anybody know what is the status of this bug?

dcoan604
5 Mar 2012, 1:20 AM
Glad I found this before I posted my long winded description of the same problem.

Any word on a fix would be great.

In my case, I'm trying to reconfigure my grid with nested (hasMany) models from a related parent model.
It works great.... and I can get the correct data to show up in my grid...and I can edit it ...ONCE.

Then, if I reconfigure the grid (grabbing new related models from a different parent model)... I can no longer get cell editor to function. I don't get any errors in console though.
I can see the value of the cell.... but when I click to edit it, the value disappears, and the editor textfield doesn't show up.

If I inspect my celleditor plugin instance after the reconfigure (and after cell editing has 'broken' I see the following):




activeColumn: null
activeEditor: null
activeRecord: null
clicksToEdit: 1
...


Prior to cell editor breaking, the first three properties don't exist on the instance.

Btw I'm using 4.0.7 in Chrome

I found this in the source .js file for cellediting:



onReconfigure: function(){
this.editors.clear();// <<<<<-------
this.callParent(); },

perhaps a clue?

EDIT: I tried overriding the onReconfigure... and commented out the line "this.editors.clear()"..... and it works for me now. What is the purpose of that line?

Tychier
24 Apr 2012, 12:56 AM
Glad I found this before I posted my long winded description of the same problem.

Any word on a fix would be great.

In my case, I'm trying to reconfigure my grid with nested (hasMany) models from a related parent model.
It works great.... and I can get the correct data to show up in my grid...and I can edit it ...ONCE.

...

I have the exact same problem as dcoan604. Good job describing what's going on, by the way! Could you please post your code for overriding the onReconfigure? I have a feeling this solution will work for me aswell, until a proper fix is released.

EDIT: I've found another solution that works well for me. Simply call grid.setEditor(...) with the initial editor configuration of each column, after reconfiguring the grid:


grid.reconfigure( ... );
Ext.each(grid.columns, function(column) {
if(column.getEditor()) column.setEditor(column.getEditor().initialConfig);
});

scancubus
17 May 2012, 1:06 PM
This is not working for me. Any updates?

The trigger is a grid reconfigure.....Too bad I need to do the reconfigure..

phamel
4 Apr 2014, 5:39 AM
On 4.1.3, the bug throw with editor.onShow(..), the column editor.boundEl is missing

resolve with :



grid.reconfigure(store, newColumns);
for(var i in grid.plugins){
if(grid.plugins[i].pluginId='myPlugInId'){
grid.plugins[i] = Ext.create('Ext.grid.plugin.CellEditing', {
pluginId = 'myPlugInId',
//... other configs ...
});
}
}
grid.getView().refresh();