木子Maple先森

博客园 首页 联系 订阅 管理

easyui tree
后台获取json数据,根据前台需要的json数据格式建立bean
如:
{ "id":1,
"text":"Folder1",
"iconCls":"icon-save",
"children":[{
"text":"File1",
"checked":true }
{
"text":"Books",
"state":"open",
"attributes":{
"url":"/demo/book/abc",
"price":100
},
1. bean实体类属性 id text iconcls children(list) attributes (根据里面属性判断为map)
2. nodecontroller
@RequestMapping(value="myNodes", produces=MediaType.APPLICATION_JSON_UTF8_VALUE)
@ResponseBody
treeNode tn=new treeNode(); tn.setid= "";tn.settext="";...
list<treeNode> nodes=new arrayList<treeNode>();
nodes.add(tn);//即获取到的json数据
3.前台通过easyUI获取json数据通过树的名字,${'#mytree'}
代码如下
<script type="text/javascript">
$(function(){
//当页面加载完毕之后,初始化树
$('#myTree').tree({
url:'<%=basePath%>getMenu.do',
onClick:function(node){
alert(node.attributes.url);
if ($('#myTree').tree('isLeaf',node.target)) {
$("#myTabs").tabs('add',{
title:node.text,
href:"<%=basePath%>" + node.text,
closable:true,
iconCls:'icon-ok'

posted on 2016-11-21 20:39  木子Maple先森  阅读(289)  评论(0编辑  收藏  举报