openlaszlo添另删除树节点

  1. <canvas debug="true" fontsize="12">   
        <include href="lz/tree.lzx"/>   
        <dataset name="treedata">   
            <root>   
                <project name="演示方案" isleaf="false">   
                    <scheme name="业务模型一" isleaf="false">   
                        <item name="业务协作流程图" isleaf="true"/>                    
                        <item name="组织机构图" isleaf="true"/>                      
                    </scheme>   
                    <scheme name="业务模型二" isleaf="false">   
                        <item name="业务协作流程图" isleaf="true"/>                    
                        <item name="组织机构图" isleaf="true"/>                          
                    </scheme>   
                </project>      
                <project name="视频" isleaf="false">   
                    <scheme name="视频分类一" isleaf="false">   
                        <item name="视频一" isleaf="true"/>                    
                    </scheme>   
                    <scheme name="视频分类二" isleaf="false">   
                        <item name="视频一" isleaf="true"/>                    
                    </scheme>   
                </project>   
                <project name="图片" isleaf="false">   
                    <scheme name="图片分类一" isleaf="false">   
                        <item name="图片一" isleaf="true"/>                    
                    </scheme>   
                    <scheme name="图片分类二" isleaf="false">   
                        <item name="图片一" isleaf="true"/>                    
                    </scheme>   
                </project>   
            </root>         
        </dataset>   
        <handler name="oninit">   
            canvas.treecontainer.projecttree.datapath.setPointer(treedata.childNodes[0]);    
        </handler>   
        <!--*** save the selected item ***-->   
        <attribute name="selecteditem" value="null"/>   
        <button name="adddir" x="0" y="4" text="Add Dir" height="24">   
            <handler name="onclick">   
                if(canvas.selecteditem==null){    
                   var projectnode = new LzDataElement('project');    
                   projectnode.setAttr('name','NEW DIR');    
                   projectnode.setAttr('isleaf',false);    
                   canvas.treecontainer.projecttree.datapath.p.appendChild(projectnode);    
                }    
            </handler>   
        </button>   
        <button name="deldir" x="80" y="4" text="Del Dir" height="24">   
            <handler name="onclick">   
                if(canvas.selecteditem!=null){    
                    canvas.selecteditem.deleteNode();    
                    canvas.selecteditem = null;    
                }    
            </handler>   
        </button>   
        <view name="treecontainer" x="10" y="30" width="200" height="400" bgcolor="#F5F5F5" clip="true">   
            <tree name="projecttree" text="分类目录" datapath="" isleaf="false" open="true">   
                <tree datapath="*"  text="$path{'@name'}" xindent="20" y="18" closesiblings="false" expander="lztree_plusminus_rsc" isleaf="$path{'@isleaf'}">   
                    <handler name="onclick">   
                        canvas.selecteditem =this.datapath;    
                    </handler>   
                </tree>   
            </tree>   
            <scrollbar/>   
        </view>     
    </canvas>

转载:http://lwz7512.iteye.com/blog/115236

 

 

你可能感兴趣的:(Scheme,Blog)