• EasyUI Tree添加节点


    创建foods tree
    首先,我们创建foods tree,代码像这样:
    <div style="200px;height:auto;border:1px solid #ccc;">
    
        <ul id="tt" class="easyui-tree" url="tree_data.json"></ul>
    
    </div>
    
    
    注意,tree组件被定义在UL标记,tree节点数据载入tree_data.json。

    得到父节点
    我们点击节点以选择fruit节点,我们添加一些fruits数据。调用getSelected方法来得到节点handle。
    var node = $('#tt').tree('getSelected');
    
    
    getSelect方法的返回值是一个js对象,包括id,text,attributes和target属性。target属性是DOM对象,引用了被选择的节点,使用append方法添加节点。
    添加节点:
    var node = $('#tt').tree('getSelected');
    
    if (node){
    
        var nodes = [{
    
            "id":13,
    
            "text":"Raspberry"
    
        },{
    
            "id":14,
    
            "text":"Cantaloupe"
    
        }];
    
        $('#tt').tree('append', {
    
            parent:node.target,
    
            data:nodes
    
        });
    
    }
    
    
    当我们添加一些fruits,可以看到:
  • 相关阅读:
    绿色版 notepad++ 添加鼠标右键菜单
    Scala 安装与配置
    Scala 神奇的下划线 _
    Kafka 安装部署
    Pulsar 下一代消息平台
    Sqoop 安装部署
    Flume 常用配置项
    Android-selector
    android- 9patch
    有关内存的思考题
  • 原文地址:https://www.cnblogs.com/huangf714/p/5911796.html
Copyright © 2020-2023  润新知