Cancel edit of tree node

1.) I have an editable tree of folders.

2.) I want to rename one of the folders text from “Folder 1” to “Folder 2”

3.) Let’s say I get an error while trying to do something on the server in response to this action, I then return a custom error and handle it using the myDataProcessor.defineAction(“error_123”,myHandler) custom handler.



My question is, what is the easiest way to set the node text back to its original text? By the time the error is returned to the client, the node has already been updated to “Folder 2”, but if there is an error on the server, I want to set it back to “Folder 1”.


Hello,


You can set onEdit event handler to get the original text of the item:


tree.attachEvent(“onEdit”,doOnEdit);


function doOnEdit(state,id,tree,value){


if(state == 0) tree.setUserData(id,“label”,value)


return true


}


And if you get error response, you can change the item text (item id should be passed with the response xml):


tree.setItemText(itemId,tree.getUserData(itemId,“label”));

Perfect. Thanks.