当前位置:网站首页>easyui tree
easyui tree
2022-07-28 17:36:00 【yoki 】
In the recent project, some data will be displayed with trees , So I looked for it , Finally found out easyui. He provided many trees , I use a tree with checkboxes , So the following will mainly introduce the simple usage of the tree with check box .
First, let's see what the tree looks like

Yes , It's like the ghost above .
If you want to use this tree, you must first introduce easyUI Styles and libraries for ( Be careful :easyUI It depends on jquery Of , So we need to introduce jquery To introduce easyui)

Then we need to define the container to display the tree
<ul id="tt3" class="easyui-tree" data-options="animate:true,checkbox:true"></ul>Here again id Is a must , Because this can be used to operate the tree many times id,
data-options Are some configuration parameters of this tree :
animate:true Is to make the tree expand or shrink to display animation ,
checkbox:true Is to display a tree with checkboxes ,
url: Hyperlinks Used to load y Hyperlink address of remote data ,
method:post/get Access to data http Request method ,
onlyLeafCheck:false Whether the check box is displayed only at the leaf node ,
dnd:false Whether drag and drop is supported
data:arry Node data to be loaded
Note that each node must have a fixed format , Otherwise it won't be recognized . Each node includes the following :
- id: Unique identification of the node .
- text: The text displayed on the node .
- checked: Whether the node is selected .
- attributes: Custom attributes of nodes .
- target: The goal is DOM object .
I have a simple tree data here
var rootData = [ { id: '1', name: ' This is the first floor (1)', 'children': [ { id: '1.1', name: ' This is the second floor (1.1)', 'children': [ { id: '1.1.1', name: ' This is the third level (1.1.1)', 'children': [] }, { id: '1.1.2', checked: 'true', name: ' This is the third level (1.1.2)', 'children': [] } ] }, { id: '1.2', name: ' This is the second floor (1.2)', 'children': [] }, { id: '1.3', name: ' This is the second floor (1.3)', 'children': [] } ] }, { id: '2', name: ' This is the first floor (2)', 'children': [ { id: '2.1', name: ' This is the second floor (2.1)', 'children': [] }, { id: '2.2', name: ' This is the second floor (2.2)', 'children': [] }, { id: '2.3', name: ' This is the second floor (2.3)', 'children': [] } ] }, { id: '3', name: ' This is the first floor (3)', 'children': [] } ];
Many people see this data and find that my tree is not used text It's using name ;( In fact, the data in my project is name So I changed easyui The library of )

here Of item Is the object of each node , After I change this, I can display the name of the tree node
How to assign the number of this tree to the one above id by tt3 Of div Well ? In fact, it's very simple, just a simple line js The code can be implemented
$('#tt3').tree({ data: rootData});
Since it is checked , So how to find the node of the tree we have checked is a very important thing , Of course easyui It still provides methods , This method is
var chsoeNodeArry = [ ]; chsoeNodeArry = $('#tt3').tree('getChecked');Through this method, we can get an array of all nodes checked .
Of course, there are many operations on trees ,easyui It also provides many events and methods
For example, click a node to edit it
<ul id="tt" class="easyui-tree" data-options="url:'tree_data.json',animate:true,onClick:function(node){$(this).tree('beginEdit',node.target)}"></ul>
You can go here jQuery EasyUI 1.3 Chinese document -- Data tables and tree menus Go to see more events and methods .
边栏推荐
- Can‘t use an undefined value as an ARRAY reference at probe2symbol
- AMQP protocol details
- Verilog 每日一题(VL4 移位运算与乘法)
- 谈谈“发布后问题”的度量
- Encrypt the video and upload it to OSS to achieve high concurrent access
- [CDH] configure CDH components through clouderamanager and collect JMX information with Prometheus monitoring
- Jdwp unauthorized rapid utilization
- The practice of beego framework developed by goweb: Section 4 database configuration and connection
- 【impala】【报错解决】 Impala cannot read or execute the parent directory of dfs.domain.socket.path的解决方法
- Verilog daily question (vl5 signal generator)
猜你喜欢

Zero foundation uses unity3d to develop AR applications and download 3D models remotely

MySQL triggers

生信人的20个R语言习题

Verilog 每日一题(VL29 单端口RAM)

高速电路设计实践——概述

Verilog daily question (vl29 single port RAM)

产品研发中第三方技术服务的管理

The actual combat of the beego framework of goweb development: Section III program execution process analysis

【impala】【报错解决】 Impala cannot read or execute the parent directory of dfs.domain.socket.path的解决方法

The practice of beego framework developed by goweb: Section 4 database configuration and connection
随机推荐
Verilog 每日一题 (VL24 多bit MUX同步器 跨时域输出)
Wechat applet cash red packet returns the error "the IP address is not the available IP address you set on the merchant platform". The ultimate solution
Mysql database development specification
js将本地时间与服务器时间同步
MySQL triggers
LNMP源码编译安装
C language to achieve minesweeping games
Master JVM interview topics and answers offer get soft (with learning roadmap)
Jdwp unauthorized rapid utilization
dos命令大全 基础命令+网络的常用命令
技术面轻松通过,HR:只有三年大厂经验的不值20K
Embedded development learning path
你能读懂这个故事吗?
Insert text watermark in PDF
FreeRTOS learning notes
MySQL PgSQL realizes the merging of multiple lines of records into one line, grouping and merging, and dividing with specified characters
JDWP未授权快速利用
Encrypt the video and upload it to OSS to achieve high concurrent access
AMQP协议详解
Opencv based real-time stitching of simple dual camera images