Renaming an item with HTML in it

I need several clickable icons in front of my item text so I write HTML to it. But I also need to rename those items. Usually this works just fine. When the editing mode is started, my item text (including the icons) is replaced by a textbox with just the old text in it. When I press return, the new text is written to the item text and I can get it in the OnEdit handler with getItemText().

But if I don’t press return but leave editing mode by clicking somewhere else in the tree, then this does not work.

The problem seems to be in these lines:

dhtmlXTreeObject.prototype._stopEdit = function (a, b) { if (this._editCell && (this.dADTempOff = this.dADTempOffEd, != a)) { var c = !0; b ? (c = !1, this.callEvent("onEditCancel", [, this._editCell._oldValue])) : c = this.callEvent("onEdit", [2,, this, this._editCell.span.childNodes[0].value]);

b always seems to be undefined, so in the last line the onEdit handler is called with this._editCell.span.childNodes[0].value as parameter. This is fine when you press return. Then the span is still what has been set in dhtmlXTreeObject.prototype._editItem.
But when I leave editing mode by clicking on a different item then this._editCell.span is the span.standartTreeRow and thus contains the whole item HTML and not the input.intreeeditRow. As the first node in my HTML has no value, undefined is passed to the onEdit handler.

I worked around this by checking the type of value in my onEdit handler, but this still should be fixed.

__treeNode_OnEdit = function(state, treeNodeId, tree, value) { switch(state) { case 0: return true; case 1: return; case 2: return typeof value == "String" && value !== ""; case 3: restoreItemHtml(this.treeObject.getItemText(treeNodeId)); } }

I need several clickable icons in front of my item text so I write HTML to it

You can use one of the following approaches:

tree.attachEvent("onEdit", function(state,id,tree,value){ if(state == 1){ // value argument - item text // here you should return value that you want to see in editor (exclude images) if(...){ .... return ... } } if(state == 2){ // value argument - text from editor // here you should return the text that you want to see as tree item (add images) if(...){ .... return ... } } return true; })