Hi~
I have a tree with a context menu (to rename a node) that when clicked on it makes that node editable.
My issue is with setOnEditHandler, when the state = 1 (editor launched) the text of the node gets lost and becomes “undefined”.
I’ve tried using tree.setItemText which unfortunately causes a postback…
Any ideas?
Here is the relevant part of my code:
menu1.attachEvent("onClick", contextClick);
xtree.setOnEditHandler(checkText);
xtree.enableContextMenu(menu);
function checkText(state, id, tree, value)
{
if(state == 0) //start editing
{
nodeText = value;
}
if(state == 1) //editor launched
{
var mynewText = "<INPUT class=intreeeditRow value=" + nodeText + " type=text>";
xtree.setItemText(id, mynewText);
}
if(state ==2) //editor about to close
{
var regex = new RegExp("^[\\w\\-\\' ]+$");
if (regex.test(value))
{
return true;
}
else
{
return false;
}
}
if(state == 3) //editor closed
{
xtree.enableItemEditor(false);
}
}
function contextClick(id, zoneId, casState)
{
if(id=="rename")
{
xtree.enableItemEditor(true);
xtree.editItem(nodeid);
}
}