jQuery EasyUI結(jié)合zTree樹(shù)形結(jié)構(gòu)制作web頁(yè)面
JQuery EasyUI 結(jié)合 zTree樹(shù)形結(jié)構(gòu)制作web頁(yè)面.easyui用起來(lái)比較簡(jiǎn)單,很好的封裝了jquery的部分功能,使用起來(lái)更加方便,但是從1.2.3版本以后,商業(yè)用途是需要付費(fèi)的,zTree是國(guó)內(nèi)的大牛們搞的一個(gè)jquery樹(shù)形tree插件,感覺(jué)很好用,很強(qiáng)大,而且完全免費(fèi),API等做的也非常不錯(cuò).推薦
easyui 是一個(gè)基于 jQuery 的框架,集成了各種用戶(hù)界面插件。
easyui 提供建立現(xiàn)代化的具有交互性的 javascript 應(yīng)用的必要的功能。
使用 easyui,您不需要寫(xiě)太多 javascript 代碼,一般情況下您只需要使用一些 html 標(biāo)記來(lái)定義用戶(hù)界面。
HTML 網(wǎng)頁(yè)的完整框架。
easyui 節(jié)省了開(kāi)發(fā)產(chǎn)品的時(shí)間和規(guī)模。
easyui 非常簡(jiǎn)單,但是功能非常強(qiáng)大。
需要的導(dǎo)入以下幾種js文件和樣式表
easyui/themes/default/easyui.css
easyui/themes/icon.css
jquery-1.8.3.js
easyui/jquery.easyui.min.js
ztree/jquery.ztree.all-3.5.js(該文件包括core,exhide,exedit,excheck)
ztree/zTreeStyle.css
<script type="text/javascript">
// ztree菜單設(shè)置
var zTreeObj,
setting = {
view: {
selectedMulti: false
},
// 添加編輯設(shè)置:修改樹(shù)節(jié)點(diǎn)名稱(chēng)/刪除樹(shù)節(jié)點(diǎn)
edit: {
enable: true
},
data: {
simpleData: {
enable: true
}
},
callback:{
onClick: zTreeOnClick
}
};
// 回調(diào)函數(shù):單擊事件
function zTreeOnClick(event, treeId, treeNode, clickFlag) {
alert(treeNode.id + ", " + treeNode.name);
var content = '<div style="width:100%;height:100% ;overflow:hidden;">'
+'<iframe src="'
+treeNode.url
+'" scrolling="auto" style="width:100%;height:100%;border:0;"></iframe></div>';
if(treeNode.url != undefined && treeNode.url != ""){
// 當(dāng)centre中是否存在名稱(chēng)為treeNode.name的tabs
if($("#tt").tabs('exists',treeNode.name)){
$("#tt").tabs('select',treeNode.name);
}else {
$("#tt").tabs('add',{
title:treeNode.name,
content:content,
closable:true
})
}
};
event.preventDefault();
};
// 提供ztree樹(shù)形菜單數(shù)據(jù)
zTreeNodes = [ {"id":1, "pId":0, "name":"海賊王"},
{"id":11, "pId":1, "name":"娜美", "url":"http://man.linuxde.net/"},
{"id":12, "pId":1, "name":"羅賓", "url":"http://www.baidu.com"},
{"id":13, "pId":1, "name":"漢庫(kù)克", "url":"http://www.google.cn/"},
{ "id":2, "pId":0, "name":"父節(jié)點(diǎn) 2", "open":true},
{"id":21,"pId":2, "name":"葉子節(jié)點(diǎn) 2-1"},
{"id":22, "pId":2, "name":"葉子節(jié)點(diǎn) 2-2"},
{"id":23,"pId":2, "name":"葉子節(jié)點(diǎn) 2-3"},
{"id":3, "pId":0, "name":"父節(jié)點(diǎn) 3", "open":true},
{"id":31, "pId":3, "name":"葉子節(jié)點(diǎn) 3-1"},
{"id":32, "pId":3, "name":"葉子節(jié)點(diǎn) 3-2"},
{"id":33, "pId":3, "name":"葉子節(jié)點(diǎn) 3-3"}
];
// 3.生成樹(shù)形菜單
$(document).ready(function(){
zTreeObj = $.fn.zTree.init($("#tree"), setting, zTreeNodes);
});
// 4.對(duì)象選項(xiàng)卡注冊(cè)右擊事件
$(document).ready(function(){
$("#tt").tabs({
onContextMenu:function(e,title,index){
// 阻止系統(tǒng)默認(rèn)的右擊事件
e.preventDefault();
$('#mm').menu('show', {
left: e.pageX,
top: e.pageY
});
}
});
});
// 獲取所選取的面板對(duì)象
$(document).ready(function(){
$("#tt").tabs({
// 獲取所選取的面板對(duì)象
onSelect : function(title,index ){
// 5. menu的單擊事件綁定
$("#mm").menu({
onClick:function(item){
alert(item.name);
// 當(dāng)點(diǎn)擊關(guān)閉當(dāng)前選項(xiàng)卡時(shí)
if(item.name==='current'){
$('#tt').tabs('close',title);
// 當(dāng)點(diǎn)擊關(guān)閉其他選項(xiàng)卡時(shí)
}else if(item.name === 'others'){
var tabs = $('#tt').tabs('tabs');
$(tabs).each(function(){
if($(this).panel('options').title != '消息中心' && $(this).panel('options').title != title){
$('#tt').tabs('close',$(this).panel('options').title);
}
});
// 當(dāng)點(diǎn)擊關(guān)閉所有選項(xiàng)卡時(shí)
}else if(item.name === 'all'){
var tabs = $('#tt').tabs('tabs');
$(tabs).each(function(){
if($(this).panel('options').title != '消息中心'){
$('#tt').tabs('close',$(this).panel('options').title);
}
});
}
}
});
}
})
})
</script>
相應(yīng)的htm 部分代碼
<body class="easyui-layout">
<div data-options="region:'north',title:'北丐:洪七公',split:true" style="height:100px;"></div>
<div data-options="region:'south',title:'南帝:一燈大師',split:true" style="height:100px;"></div>
<div data-options="region:'east',iconCls:'icon-reload',title:'東邪:黃藥師',split:true" style="width:100px;"></div>
<div data-options="region:'west',title:'西毒:歐陽(yáng)鋒',split:true" style="width:250px;">
<div id="aa" data-options="fit:'true'" class="easyui-accordion">
<div title="趙敏" data-options="iconCls:'icon-save'" >
<h3 style="color:#0099FF;">Accordion for jQuery</h3>
<p>Accordion is a part of easyui framework for jQuery. It lets you define your accordion component on web page more easily.</p>
</div>
<div title="大玉兒" data-options="iconCls:'icon-reload',selected:true" >
// ztree屬性結(jié)構(gòu)
<ul id="tree" class="ztree" style="width:230px; overflow:auto;"></ul>
</div>
<div title="婉容兒" >
who?
</div>
</div>
</div>
<div data-options="region:'center',title:'中神通:周伯通'">
// tabs 面板
<div id="tt" class="easyui-tabs" data-options="fit:true">
<div title="小龍女"data-options="closable:true" ></div>
<div title="沐劍屏" data-options="closable:true" ></div>
<div title="阿珂" data-options="iconCls:'icon-reload',closable:true"></div>
</div>
</div>
// menu菜單欄
<div id="mm" class="easyui-menu" style="width:120px;">
<div name="current">關(guān)閉當(dāng)前選項(xiàng)卡</div>
<div name="others">關(guān)閉其他選項(xiàng)卡</div>
<div class="menu-sep"></div>
<div data-options="iconCls:'icon-cancle'" name="all">關(guān)閉所有選項(xiàng)卡</div>
</div>
</body>
以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。
- 基于jQuery ztree實(shí)現(xiàn)表格風(fēng)格的樹(shù)狀結(jié)構(gòu)
- jQuery zTree 異步加載添加子節(jié)點(diǎn)重復(fù)問(wèn)題
- jQuery 利用ztree實(shí)現(xiàn)樹(shù)形表格的實(shí)例代碼
- zTree jQuery 樹(shù)插件的使用(實(shí)例講解)
- jQuery使用zTree插件實(shí)現(xiàn)可拖拽的樹(shù)示例
- jQuery zTree樹(shù)插件動(dòng)態(tài)加載實(shí)例代碼
- jQuery插件zTree實(shí)現(xiàn)的多選樹(shù)效果示例
- jQuery zTree如何改變指定節(jié)點(diǎn)文本樣式
相關(guān)文章
jQuery插件StickUp實(shí)現(xiàn)網(wǎng)頁(yè)導(dǎo)航置頂
本文給大家介紹的是一款jQuery插件--StickUp,他的主要用途是實(shí)現(xiàn)網(wǎng)頁(yè)元素固定,如導(dǎo)航固定讓其總是保持在視圖中可見(jiàn),效果非常不錯(cuò),這里推薦給小伙伴們。2015-04-04
jquery兩種導(dǎo)入方式之本地導(dǎo)入和線上導(dǎo)入
這篇文章主要給大家介紹了關(guān)于jquery兩種導(dǎo)入方式之本地導(dǎo)入和線上導(dǎo)入的相關(guān)資料,jQuery是一款JavaScript庫(kù),封裝了JavaScript相關(guān)方法調(diào)用,文中通過(guò)代碼介紹的非常詳細(xì),需要的朋友可以參考下2023-11-11
jquery無(wú)法設(shè)置checkbox選中即沒(méi)有變成選中狀態(tài)
設(shè)置以后checkbox并沒(méi)有變成選中狀態(tài),用chrome調(diào)試看了一下,checkbox中確實(shí)有checked屬性,針對(duì)這個(gè)問(wèn)題,大家可以參考下本文2014-03-03
jquery 字符串切割函數(shù)substring的用法說(shuō)明
本篇文章主要是對(duì)jquery字符串切割函數(shù)substring的用法進(jìn)行了介紹,需要的朋友可以過(guò)來(lái)參考下,希望對(duì)大家有所幫助2014-02-02
基于jQuery排序及應(yīng)用實(shí)現(xiàn)Tab欄特效
這篇文章主要介紹了基于jQuery排序及應(yīng)用實(shí)現(xiàn)Tab欄特效,jquery是基于JavaScript語(yǔ)言寫(xiě)出來(lái)的一個(gè)框架,它封裝JavaScript常用的功能代碼,提供一種簡(jiǎn)便的JavaScript設(shè)計(jì)模式,但實(shí)質(zhì)上還是js,所以JQuery也屬于網(wǎng)頁(yè)編程語(yǔ)言。下面更多內(nèi)容需要的小伙伴可以參考一下2022-03-03
使用jquery判斷一個(gè)元素是否含有一個(gè)指定的類(lèi)(class)實(shí)例
下面小編就為大家?guī)?lái)一篇使用jquery判斷一個(gè)元素是否含有一個(gè)指定的類(lèi)(class)實(shí)例。小編覺(jué)得挺不錯(cuò)的,現(xiàn)在就分享給大家,也給大家做個(gè)參考。一起跟隨小編過(guò)來(lái)看看吧2017-02-02

