站内搜索:
首页 >> 前端 >> 内容
easyui-tree显示到指定层次

时间:2017/7/1 9:27:00

easyui-tree显示到指定层次

要求

返回的树形结构中有一个属性表示当前节点的层次,这里是type

代码

var expendFunction = function (treeNodes) {  
        //var treeNodes = $('#tt').tree('getRoots');  
        $(treeNodes).each(function () {  
            var data = $('#tt').tree('getData', this.target);  
            if (data.type < 2) {  
                $('#tt').tree('expand', this.target);  
                expendFunction($('#tt').tree('getChildren', this.target));  
            }  
        })  
    };  

tt是树形结构的Id.
调用:

$('#tt').tree({  
    url: url,  
    queryParams: filter,  
    onLoadSuccess: function (node, data) {  
        if (data) {  
            $('#tt').tree('collapseAll');  
            var Roots = $('#tt').tree('getRoots');  
            expendFunction(Roots);  
        }   
    }  
});  

  • 上一篇:todolist(jQuery实现)
  • 下一篇:深入解读-小程序SDK
  • 返回顶部