EasyUi之Tree组件(一)

EasyUi tree组件

树控件在web页面中一个将分层数据以树形结构进行显示。它提供用户展开、折叠、拖拽、编辑和异步加载等功能。
在这里插入图片描述
树结构的数据是在同一个表中,A数据的id是B数据的外键,以此表示A节点的下一级节点为B。
在这里插入图片描述
如上图,新增的pid与书籍管理的id值是相同的,那么,书籍管理就是新增的父节点。如果pid为0的话就是没有父节点。

Tree组件案例

jsp页面

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<!-- 全局样式 -->
<link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath }/static/js/jquery-easyui-1.5.1/themes/default/easyui.css">   
<!-- 定义图标 -->
<link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath }/static/js/jquery-easyui-1.5.1/themes/default/easyui.css"> 
<script type="text/javascript" src="${pageContext.request.contextPath }/static/js/jquery-easyui-1.5.1/jquery.min.js"></script>   
<!-- 组件库源码的js文件 -->  
<script type="text/javascript" 
	src="${pageContext.request.contextPath }/static/js/jquery-easyui-1.5.1/jquery.easyui.min.js"></script>  
	//写一个文件,专门写js代码
	<script type="text/javascript" 
	src="${pageContext.request.contextPath }/static/js/index.js"></script>  
<title>登录后的主界面</title>
</head>
<body class="easyui-layout">
	<div data-options="region:'north',border:false" 
	  	style="height:60px;background:#B3DFDA;padding:10px">nt管理系统
	  </div>
	<div data-options="region:'west',split:true,title:'West'" 
		style="width:150px;padding:10px;">
		<ul id="tt"></ul> //调用js里面的函数
	</div>
	<div data-options="region:'east',split:true,collapsed:true,title:'East'"
	 	style="width:100px;padding:10px;">east region
	 </div>
	<div data-options="region:'south',border:false"
	 	style="height:50px;background:#A9FACD;padding:10px;">south region
	 </div>
	<div data-options="region:'center',title:'Center'"></div>
</body>
</html>

index.js代码,函数里面调用json

$(function(){
   
	$('#tt').tree({
       
	    url:'tree_data1.json'   
	});  
})

json里面的代码

[{
   
	"id":1,
	"text":"My Documents",
	"children":[{
   
		"id":11,
		"text":"Photos",
		"state":"closed",
		"children":[{
   
			"id":111,
			"text":"Friend"
		},{
   
			"id":112,
			"text":"Wife"
		},{
   
			"id":113,
			"text":"Company"
		}]
	},{
   
		"id":12,
		"text":"Program Files",
		"children":[{
   
			"id":121,
			"text":"Intel"
		},{
   
			"id":122,
			"text":"Java",
			"attributes":{
   
				"p1":"Custom Attribute1",
				"p2":"Custom Attribute2"
			}
		},{
   
			"id":123,
			"text":"Microsoft Office"
		},{
   
			"id":124,
			"text":"Games",
			"checked":true
		}]
	},{
   
		"id":13,
		"text":"index.html"
	},{
   
		"id":14,
		"text":"about.html"
	},{
   
		"id":15,
		"text":"welcome.html"
	}]
}]

现在我们就将数据库里的数据展示出来
以上面数据表的数据为例
实体类

package com.zhangsiwen.entity;

public class Permission {
   
	private long id;
	private String name;
	private String description;
	private String url;
	private long pid;
	private int ismenu;
	private long displayno;
	public long getId() {
   
		return id;
	}
	public void setId(long id) {
   
		this.id = id
  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值