PDA

View Full Version : [OPEN] [CLOSED-528][3.??] TreeEditor problem wih TreeGrid (editor field does not populate)



joncheck
4 Feb 2010, 9:03 AM
UPDATE: Made a second fix to my triggerEdit override (code is updated below), which fixed a problem in IE (and other non-gecko browsers) where a leaf value would disappear when clicking on it to edit.

I recently converted a TreePanel to an Ext.ux.tree.TreeGrid, and I noticed a problem with the TreeEditor (for inline editing of tree node text). When I clicked a node to edit, the TextField editor would appear, but it was blank (rather than showing the existing node value as the "default" value to edit).

I could not find a solution (or relevant post) for this in the ext forums, so I took a look at the code, and discovered that the the triggerEdit method could be tweaked to solve the problem. Rather than using node.text to prepopulate the editor field, the fix also looks at node.attributes.name (which seems to be more compatible with TreeGrid).

Here's the fix as I implemented it (the key change is in bold):


Ext.override(Ext.tree.TreeEditor, {

triggerEdit : function(node, defer){
this.completeEdit();
if(node.attributes.editable !== false){

this.editNode = node;
if(this.tree.autoScroll){
Ext.fly(node.ui.getEl()).scrollIntoView(this.tree.body);
}
var value = node.text || node.attributes.name || '';
if (!Ext.isGecko && Ext.isEmpty(value)){
node.setText(' ');
}
this.autoEditTimer = this.startEdit.defer(this.editDelay, this, [node.ui.textNode, value]);
return false;
}
}
});

tolstoj
20 Feb 2010, 10:16 PM
Excellent solution. Thank you!

Cheers

evant
21 Jun 2010, 12:05 AM
Useful information, but I wouldn't consider this a bug. Defaulting the property only works for a single column. In future it would be good to implement an editor that works on all columns, which is likely to happen when the TreeGrid is refactored at a later point. As such, I'll close this off.