From Porcupine wiki

CookBook: Adding tree nodes dynamically

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="">
	<treenode caption="test" id="test" haschildren="true">				

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


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

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