本文共 1636 字,大约阅读时间需要 5 分钟。
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); } }});
//扩展Easyui-tree 获取一级子节点$.extend($.fn.tree.methods, { getLeafChildren: function (jq, params) { var nodes = []; $(params).next().children().children("div.tree-node").each(function () { nodes.push($(jq[0]).tree('getNode', this)); }); return nodes; }});注:此方法来自互联网。
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('getLeafChildren', this.target)); } }) };
转载地址:http://qehji.baihongyu.com/