PDA

View Full Version : [UNKNOWN][3.??] RowEditor reconfigure after grid reconfigure



zvds
22 Dec 2009, 7:08 AM
I discovered that roweditor don't update its columns after grid reconfigure.
It is because it don't destroy its columns in right way in function initFields, line this.removeAll(false); don't remove elements from DOM of browser, so after few switches we get many fields inside roweditor element.

So how remove them in best way?



initFields: function(){
var cm = this.grid.getColumnModel(), pm = Ext.layout.ContainerLayout.prototype.parseMargins;
this.removeAll(false);
for(var i = 0, len = cm.getColumnCount(); i < len; i++){
var c = cm.getColumnAt(i),
ed = c.getEditor();
if(!ed){
ed = c.displayEditor || new Ext.form.DisplayField();
}
if(i == 0){
ed.margins = pm('0 1 2 1');
} else if(i == len - 1){
ed.margins = pm('0 0 2 1');
} else{
ed.margins = pm('0 1 2');
}
ed.setWidth(cm.getColumnWidth(i));
ed.column = c;
if(ed.ownerCt !== this){
ed.on('focus', this.ensureVisible, this);
ed.on('specialkey', this.onKey, this);
}
this.insert(i, ed);
}
this.initialized = true;
}

hendricd
22 Dec 2009, 12:07 PM
Have you tried this.removeAll(true); ?

That should remove all the editors from the DOM.

zvds
22 Dec 2009, 11:28 PM
yes, I tried, but on next reconfigure don't work. I think it starts it again before show and removes components that should be in it..

letssurf
7 Jan 2010, 2:28 AM
I'm having the same problem. Leave the removeAll value to false leaves all the dom items in the editor which can be seen after a reconfigure.

removeAll true destroys them but causes an error on the next time the editor is shown. Needs fixing but can't work out why the error occurs.

as a work around I've done



if (this.items) {
this.items.each(function(cmp) {
cmp.hide();
});
}
this.removeAll(false);


Which hides them. Problem with this long term is that leaves alot of editor objects in memory.

letssurf
7 Jan 2010, 4:31 AM
As a quick easy way of seeing the problem and testing it. I'm using the /examples/grid/row-editor.html

in row-editor.js I've edited line 101 and added


{
text: 'Reconfigure',
handler: function() {
grid.reconfigure(grid.store, grid.getColumnModel());
}
}

Reconfigures the editor with the same store and column model.

Double clicking a row and getting the editor the first time always works, even if reconfigure has been pressed. After the roweditor has been displayed at least once then pressing reconfigure is where the problem is. After this has been done the roweditor looks odd (see screen shot). This is because the previous editor items although arn't an item of the roweditor container anymore still have there rendering in the roweditor.

Changing line 253 of RowEditor.js


initFields: function(){
var cm = this.grid.getColumnModel(), pm = Ext.layout.ContainerLayout.prototype.parseMargins;
this.removeAll(true);


Following the same steps causes the roweditor to error and not be displayed at all.

Please Help...

letssurf
7 Jan 2010, 6:24 AM
Just found it only does this if theres an Ext.form.DateField or a Ext.form.TimeField as one of the editors.
Maybe something todo with triggerfields?

letssurf
8 Jan 2010, 3:46 AM
I know this is my fourth post in a row :"> my bad.

I think this issue will be fixed by http://www.extjs.com/forum/showthread.php?p=425309#post425309

As I no longer have a support license and svn access (gonna remind bosses today to renew) I can't check this.

Fingers crossed.

zvds
12 Jan 2010, 1:58 AM
I tryed to solved this problem using

this.removeAll(true);
and setting in combobox config of field editor

removeMode: 'el',
and realy errors was because triggerfield and its children classes, which removed container after this.removeAll(true)

but erorrs apear after second call of the same configuration