EasyUI Tree添加节点


创建foods tree
首先,我们创建foods tree,代码像这样:
<div style="width: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,可以看到:
\

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM