The following JavaScript function adds a new node to the WebTree, as a child of the selected node. It will be called by the onclick event of an HTML button.
In java Script
function AddChild()
{
var tree = igtree_getTreeById("UltraWebTree1");
var node = tree.getSelectedNode();
var newnode;
if (node)
{
newnode = node.addChild("Added Node");
newnode.setTag("'AddedNode' Tag");
}
}
The following JavaScript function removes the last child node of the selected node from the WebTree. It will be called by the onclick event of another HTML button.
In JavaScript:
function RemoveChild()
{
var tree = igtree_getTreeById("UltraWebTree1");
var node = tree.getSelectedNode();
if (node)
{
var cnodes = node.getChildNodes();
if (cnodes.length == 0)
return;
var cnode = cnodes[cnodes.length - 1];
cnode.remove();
}
}
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment