Add node to tree and activate edit

Hi Guys

I’d like users to be able to add new nodes to a tree, the process is they click the + button, an empty node is added and then the “Edit” is automatically activated. The issue I have is, I’m not sure how programmatically fire the Edit on a tree node, I thought it would be something like this -

		var clickAddCategory = function() {
			var tree = $$("category_tree");
			var row_id = tree.add({}, 0, tree.getSelectedId());
			tree.editRow(row_id);
		}

The node gets added ok, but the edit does not trigger. Any pointers on where I’m going wrong?

Also, what would be the correct method of aborted the new node, for example if the user pressed escape or click off the node without entering a value, I’d like it just to disappear and stop the Savefrom triggering.

Thanks

You code is mostly correct but you need to be sure that newly added item is visible ( is in opened branch ), so the code must be like next. And to start the edit you need to use “edit” command not “editRow” one.

var tree = $$("category_tree");
var row_id = tree.add({}, 0, tree.getSelectedId());
tree.open(tree.getSelectedId())
tree.edit(row_id);

http://webix.com/snippet/0b71aeb4

if the user pressed escape
You can use onAfterEditStop event. If user have used escape key then the third parameter will be set to true

http://webix.com/snippet/9a1c84ff