Recent Changes - Search:

Administrators

Developers

Articles

Cookbook

edit

Adding tree nodes dynamically

CookBook.AddTreeNodesDynamically History

Hide minor edits - Show changes to markup

December 14, 2007, at 10:16 AM by Stavros Charitakis -
Changed line 32 from:

Note that what is been redrawn is the newnode that we created and not the node which fired the event(nodeclicked).

to:

Note that what is been redrawn is the newnode that we created and not the node which fired the event (nodeclicked).

December 14, 2007, at 10:16 AM by Stavros Charitakis -
Changed lines 1-2 from:

title Adding tree nodes dynamically class

to:

(:title Adding tree nodes dynamically:)

December 14, 2007, at 10:16 AM by Stavros Charitakis -
Added lines 1-32:

(:title Adding tree nodes dynamically class:)

There will cases where you will need to add tree nodes on a tree dynamically. In order to do so you need to create the tree widget and use the "onexpand" event as illustrated below:

<tree width="150" onexpand="app.addNode" xmlns="http://www.innoscript.org/quix">
	<treenode caption="test" id="test" haschildren="true">				
	</treenode>
</tree>	

Next step is to add the event handler in the javascript file as such:

app.addNode = function(nodeclicked)
{
    var newnode = new TreeNode({
        caption: 'myCaption',
        haschildren: true
    });

    nodeclicked.appendChild(newnode);
    newnode.redraw();
}

Note that what is been redrawn is the newnode that we created and not the node which fired the event(nodeclicked).

Page last modified on December 14, 2007, at 10:16 AM