easyUI Tree的使用

1.添加相应的引用。

2.具体使用如下:

<script type="text/javascript">

$(function () {

//begin init

var content = '<iframe scrolling="auto" frameborder="0" id="' + tabid + '"src="' + url + '" style="width:100%;height:100%;"></iframe>';

$('#TheTab').tabs('add', {

title: "the first",

content: content,

closable: false

});

$('#TheTab').tabs('add', {

title: "the first",

content: content,

closable: false

});

//获取第一个根节点的text

var param = "<%=rootOneText%>";

//获取tree参数

InitTreeData('GetData.ashx?action=' + param);

});

//easyUI Tab

function InitTreeData(zhi) {

$('#tt').tree({

url: value,

onClick: function (node) {

if ($('#tt').tree('isLeaf', node.target)) {//判断是否是叶子节点

var str = "<%=Request.Cookies["UserInfo"].Values["UserName"]%>";

var newTab = node.text;

var topic = "QMS";

var biscode = node.id;

var prex = biscode.substring(1, 3);

//by node;

var parent = $('#tt').tree('getParent', node.target);

var Gparent = $('#tt').tree('getParent', parent.target);

var tabid = Gparent.text+parent.text+newTab;

//判断是否(未打开执行)(具体判断方式,具体对待

//if ($('#TheTab').tabs('exists', newTab)) {

if ($("#" + tabid).html() != null) {

$('#TheTab').tabs('update', newTab);

} else {

switch (prex) {}

}

//获取最后一个tabs 在新加的选项卡后面添加"关闭全部"

var li = $(".tabs-wrap ul li:last-child");

$("#close").remove();

li.after("<li id='close'><a class='tabs-inner' href='javascript:void()' onClick='javascript:closeAll()'>关闭全部</a></li>");

}

},

onDblClick: function (node) {

if (!$('#tt').tree('isLeaf', node.target)) {

//非叶节点双击展开节点

$(this).tree(node.state === 'closed' ? 'expand' : 'collapse', node.target);

node.state = node.state === 'closed' ? 'open' : 'closed';

}

}

});

}

function closeAll() {

$(".tabs li").each(function (index, obj) {

//获取所有可关闭的选项卡

var tab = $(".tabs-closable", this).text();

$(".easyui-tabs").tabs('close', tab);

});

$("#close").remove();//同时把此按钮关闭

}

猜你喜欢

转载自blog.csdn.net/miluli1/article/details/82904495