Home Web Front-end JS Tutorial Detailed example of jQuery EasyUI combined with zTree tree structure to create web pages

Detailed example of jQuery EasyUI combined with zTree tree structure to create web pages

Dec 29, 2017 am 11:32 AM
easyui jquery web

JQuery EasyUI combines the zTree tree structure to create web pages. easyui is relatively simple to use. It well encapsulates some functions of jquery and is more convenient to use. However, starting from version 1.2.3, commercial use requires payment. zTree is a jquery tree plug-in developed by domestic experts. It feels easy to use, very powerful, and completely free. The API is also very good.

easyui is a jQuery-based framework that integrates various user interface plug-ins.

easyui provides the necessary functionality to build modern interactive javascript applications.

Using easyui, you don’t need to write too much javascript code. Generally, you only need to use some html tags to define the user interface.

The complete framework of HTML web page.

easyui saves time and scale in product development.

easyui is very simple, but very powerful.

You need to import the following js files and style sheets

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(This file includes core,exhide,exedit,excheck)
ztree /zTreeStyle.css


##

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

45

46

47

48

49

50

51

52

53

54

55

56

57

58

59

60

61

62

63

64

65

66

67

68

69

70

71

72

73

74

75

76

77

78

79

80

81

82

83

84

85

86

87

88

89

90

91

92

93

94

95

96

97

98

99

100

101

102

103

104

105

106

107

108

109

110

111

112

<script type="text/javascript">  

 // ztree菜单设置

 var zTreeObj,

 setting = {

  view: {

   selectedMulti: false

  },

  // 添加编辑设置:修改树节点名称/删除树节点

  edit: {

   enable: true

  },

  data: {

   simpleData: {

    enable: true

   }

  },

  callback:{

   onClick: zTreeOnClick

  }

 };

  

 // 回调函数:单击事件

 function zTreeOnClick(event, treeId, treeNode, clickFlag) {

  alert(treeNode.id + ", " + treeNode.name);

  var content = &#39;<p style="width:100%;height:100% ;overflow:hidden;">&#39;

       +&#39;<iframe src="&#39;

       +treeNode.url

       +&#39;" scrolling="auto" style="width:100%;height:100%;border:0;"></iframe></p>&#39;;

  if(treeNode.url != undefined && treeNode.url != ""){

   // 当centre中是否存在名称为treeNode.name的tabs

   if($("#tt").tabs(&#39;exists&#39;,treeNode.name)){

    $("#tt").tabs(&#39;select&#39;,treeNode.name);

   }else {

    $("#tt").tabs(&#39;add&#39;,{

     title:treeNode.name,

     content:content,

     closable:true

    })

   }

  };

  event.preventDefault();

 };

  

 // 提供ztree树形菜单数据

 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":"汉库克", "url":"http://www.google.cn/"},

        { "id":2, "pId":0, "name":"父节点 2", "open":true},

        {"id":21,"pId":2, "name":"叶子节点 2-1"},

        {"id":22, "pId":2, "name":"叶子节点 2-2"},

        {"id":23,"pId":2, "name":"叶子节点 2-3"},

        {"id":3, "pId":0, "name":"父节点 3", "open":true},

        {"id":31, "pId":3, "name":"叶子节点 3-1"},

        {"id":32, "pId":3, "name":"叶子节点 3-2"},

        {"id":33, "pId":3, "name":"叶子节点 3-3"}

       ];

  

 // 3.生成树形菜单

 $(document).ready(function(){

  zTreeObj = $.fn.zTree.init($("#tree"), setting, zTreeNodes);

 });

  

 // 4.对象选项卡注册右击事件

 $(document).ready(function(){

  $("#tt").tabs({

   onContextMenu:function(e,title,index){

   // 阻止系统默认的右击事件

    e.preventDefault();

    $(&#39;#mm&#39;).menu(&#39;show&#39;, {

     left: e.pageX,

     top: e.pageY

    });

   }

  });

 });

  

 // 获取所选取的面板对象

 $(document).ready(function(){

  $("#tt").tabs({

   // 获取所选取的面板对象

   onSelect : function(title,index ){

    // 5. menu的单击事件绑定

    $("#mm").menu({

     onClick:function(item){

      alert(item.name);

      // 当点击关闭当前选项卡时

      if(item.name===&#39;current&#39;){

       $(&#39;#tt&#39;).tabs(&#39;close&#39;,title);

      // 当点击关闭其他选项卡时

      }else if(item.name === &#39;others&#39;){

       var tabs = $(&#39;#tt&#39;).tabs(&#39;tabs&#39;);

       $(tabs).each(function(){

        if($(this).panel(&#39;options&#39;).title != &#39;消息中心&#39; && $(this).panel(&#39;options&#39;).title != title){

         $(&#39;#tt&#39;).tabs(&#39;close&#39;,$(this).panel(&#39;options&#39;).title);

        }

       });

      // 当点击关闭所有选项卡时

      }else if(item.name === &#39;all&#39;){

       var tabs = $(&#39;#tt&#39;).tabs(&#39;tabs&#39;);

       $(tabs).each(function(){

          if($(this).panel(&#39;options&#39;).title != &#39;消息中心&#39;){

         $(&#39;#tt&#39;).tabs(&#39;close&#39;,$(this).panel(&#39;options&#39;).title);

        }

       });

      }

     }

    });

   }

  })

 })

</script>

Copy after login

Corresponding htm part code


1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

<body class="easyui-layout">

 <p data-options="region:&#39;north&#39;,title:&#39;北丐:洪七公&#39;,split:true" style="height:100px;"></p>

 <p data-options="region:&#39;south&#39;,title:&#39;南帝:一灯大师&#39;,split:true" style="height:100px;"></p>

 <p data-options="region:&#39;east&#39;,iconCls:&#39;icon-reload&#39;,title:&#39;东邪:黄药师&#39;,split:true" style="width:100px;"></p>

 <p data-options="region:&#39;west&#39;,title:&#39;西毒:欧阳锋&#39;,split:true" style="width:250px;">

  <p id="aa" data-options="fit:&#39;true&#39;" class="easyui-accordion">

   <p title="赵敏" data-options="iconCls:&#39;icon-save&#39;" >

    <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>

   </p>

   <p title="大玉儿" data-options="iconCls:&#39;icon-reload&#39;,selected:true" >

    // ztree属性结构

    <ul id="tree" class="ztree" style="width:230px; overflow:auto;"></ul>

   </p>

   <p title="婉容儿" >

    who?

   </p>

  </p>

 </p>

 <p data-options="region:&#39;center&#39;,title:&#39;中神通:周伯通&#39;">

  // tabs 面板

  <p id="tt" class="easyui-tabs" data-options="fit:true">

   <p title="小龙女"data-options="closable:true" ></p>

   <p title="沐剑屏" data-options="closable:true" ></p>

   <p title="阿珂" data-options="iconCls:&#39;icon-reload&#39;,closable:true"></p>

  </p>

 </p>

  

 // menu菜单栏

 <p id="mm" class="easyui-menu" style="width:120px;">

  <p name="current">关闭当前选项卡</p>

  <p name="others">关闭其他选项卡</p>

  <p class="menu-sep"></p>

  <p data-options="iconCls:&#39;icon-cancle&#39;" name="all">关闭所有选项卡</p>

 </p>

</body>

Copy after login

Related recommendations:

zTree asynchronously loads and expands the first level node method implementation

ztree implements dynamically generated tree on the left and content details function example sharing on the right

Detailed example of jQuery using ztree to implement tree table

The above is the detailed content of Detailed example of jQuery EasyUI combined with zTree tree structure to create web pages. For more information, please follow other related articles on the PHP Chinese website!

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Hot Topics

Java Tutorial
1663
14
PHP Tutorial
1263
29
C# Tutorial
1236
24
How to use PUT request method in jQuery? How to use PUT request method in jQuery? Feb 28, 2024 pm 03:12 PM

How to use PUT request method in jQuery? In jQuery, the method of sending a PUT request is similar to sending other types of requests, but you need to pay attention to some details and parameter settings. PUT requests are typically used to update resources, such as updating data in a database or updating files on the server. The following is a specific code example using the PUT request method in jQuery. First, make sure you include the jQuery library file, then you can send a PUT request via: $.ajax({u

jQuery Tips: Quickly modify the text of all a tags on the page jQuery Tips: Quickly modify the text of all a tags on the page Feb 28, 2024 pm 09:06 PM

Title: jQuery Tips: Quickly modify the text of all a tags on the page In web development, we often need to modify and operate elements on the page. When using jQuery, sometimes you need to modify the text content of all a tags in the page at once, which can save time and energy. The following will introduce how to use jQuery to quickly modify the text of all a tags on the page, and give specific code examples. First, we need to introduce the jQuery library file and ensure that the following code is introduced into the page: &lt

Use jQuery to modify the text content of all a tags Use jQuery to modify the text content of all a tags Feb 28, 2024 pm 05:42 PM

Title: Use jQuery to modify the text content of all a tags. jQuery is a popular JavaScript library that is widely used to handle DOM operations. In web development, we often encounter the need to modify the text content of the link tag (a tag) on ​​the page. This article will explain how to use jQuery to achieve this goal, and provide specific code examples. First, we need to introduce the jQuery library into the page. Add the following code in the HTML file:

How to enable administrative access from the cockpit web UI How to enable administrative access from the cockpit web UI Mar 20, 2024 pm 06:56 PM

Cockpit is a web-based graphical interface for Linux servers. It is mainly intended to make managing Linux servers easier for new/expert users. In this article, we will discuss Cockpit access modes and how to switch administrative access to Cockpit from CockpitWebUI. Content Topics: Cockpit Entry Modes Finding the Current Cockpit Access Mode Enable Administrative Access for Cockpit from CockpitWebUI Disabling Administrative Access for Cockpit from CockpitWebUI Conclusion Cockpit Entry Modes The cockpit has two access modes: Restricted Access: This is the default for the cockpit access mode. In this access mode you cannot access the web user from the cockpit

How to remove the height attribute of an element with jQuery? How to remove the height attribute of an element with jQuery? Feb 28, 2024 am 08:39 AM

How to remove the height attribute of an element with jQuery? In front-end development, we often encounter the need to manipulate the height attributes of elements. Sometimes, we may need to dynamically change the height of an element, and sometimes we need to remove the height attribute of an element. This article will introduce how to use jQuery to remove the height attribute of an element and provide specific code examples. Before using jQuery to operate the height attribute, we first need to understand the height attribute in CSS. The height attribute is used to set the height of an element

Understand the role and application scenarios of eq in jQuery Understand the role and application scenarios of eq in jQuery Feb 28, 2024 pm 01:15 PM

jQuery is a popular JavaScript library that is widely used to handle DOM manipulation and event handling in web pages. In jQuery, the eq() method is used to select elements at a specified index position. The specific usage and application scenarios are as follows. In jQuery, the eq() method selects the element at a specified index position. Index positions start counting from 0, i.e. the index of the first element is 0, the index of the second element is 1, and so on. The syntax of the eq() method is as follows: $("s

How to implement h5 to slide up on the web side to load the next page How to implement h5 to slide up on the web side to load the next page Mar 11, 2024 am 10:26 AM

Implementation steps: 1. Monitor the scroll event of the page; 2. Determine whether the page has scrolled to the bottom; 3. Load the next page of data; 4. Update the page scroll position.

Is PHP front-end or back-end in web development? Is PHP front-end or back-end in web development? Mar 24, 2024 pm 02:18 PM

PHP belongs to the backend in web development. PHP is a server-side scripting language, mainly used to process server-side logic and generate dynamic web content. Compared with front-end technology, PHP is more used for back-end operations such as interacting with databases, processing user requests, and generating page content. Next, specific code examples will be used to illustrate the application of PHP in back-end development. First, let's look at a simple PHP code example for connecting to a database and querying data:

See all articles