Create-on-Open for Tree Controls

As illustrated below, you could listen to the onOpen event, and then load the children of an tree item. Similarly, you could do create-on-open for group boxes.

<tree width="200px">
    <treecols>    
        <treecol label="Subject"/>        
        <treecol label="From"/>        
    </treecols>    
    <treechildren>    
        <treeitem open="false" onOpen="load()">        
            <treerow>            
                <treecell label="Intel Snares XML"/>                
                <treecell label="David Needle"/>                
            </treerow>            
            <treechildren/>            
        </treeitem>        
    </treechildren>    
    <zscript>    
    void load() {    
        Treechildren tc = self.getTreechildren();        
        if (tc.getChildren().isEmpty()) {        
            Treeitem ti = new Treeitem();            
            ti.setLabel("New added");            
            ti.setParent(tc);            
        }        
    }    
    </zscript>    
</tree>