easyui的聚合实验

点击左侧节点,在中心显示easyui标签

tree_data1.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",
			"attributes":{
				"url":"demo1.jsp",
				"p2":"Custom Attribute2"
			}
		},{
			"id":122,
			"text":"Java",
			"attributes":{
				"url":"demo2.jsp",
				"p2":"Custom Attribute2"
			}
		},{
			"id":123,
			"text":"Microsoft Office",
			"attributes":{
				"url":"../jsp/demo3.jsp",
				"p2":"Custom Attribute2"
			}
		},{
			"id":124,
			"text":"Games",
			"checked":true,
			"attributes":{
				"url":"../jsp/demo4.jsp",
				"p2":"Custom Attribute2"
			}
		}]
	},{
		"id":13,
		"text":"index.html"
	},{
		"id":14,
		"text":"about.html"
	},{
		"id":15,
		"text":"welcome.html"
	}]
}]

 treeAttributes.html

<!DOCTYPE html>
<html>
<head>
	<meta charset="UTF-8">
	<title>treeAttributes</title>
	<link rel="stylesheet" type="text/css" href="../themes/default/easyui.css">
	<link rel="stylesheet" type="text/css" href="../themes/icon.css">
	<link rel="stylesheet" type="text/css" href="../demo/demo.css">
	<script type="text/javascript" src="../jquery.min.js"></script>
	<script type="text/javascript" src="../jquery.easyui.min.js"></script>
</head>
<body class="easyui-layout">
	<div data-options="region:'north',title:'North Title',split:true"
		style="height: 100px;"></div>
	<div data-options="region:'south',title:'South Title',split:true"
		style="height: 100px;"></div>
	<div
		data-options="region:'east',iconCls:'icon-reload',title:'East',split:true"
		style="width: 100px;"></div>
	<div data-options="region:'west',title:'West',split:true"
		style="width: 200px;">
		<ul id="stuMenu"></ul>
	</div>
	<div data-options="region:'center',title:'center title'"
		style="padding: 5px; background: #eee;">
    	<div id="stuTabs" class="easyui-tabs" style="width:100%;height:100%;">    
    	</div>  
	</div>

<script type="text/javascript">
 	$(function(){
		  $('#stuMenu').tree({    
			    url:'tree_data1.json' ,
 			    onClick: function(node){
			    	//exists which 表明指定的面板是否存在,'which'参数可以是选项卡面板的标题或索引。 
			    	var exists = $('#stuTabs').tabs('exists', node.text);
			    	//判断面板是否存在
			    	if(exists){
			    		//select which 选择一个选项卡面板,'which'参数可以是选项卡面板的标题或者索引。 
			    		$('#stuTabs').tabs('select', node.text);
			    	}else{
			    		//不存在则添加面板
						$('#stuTabs').tabs('add',{    
						    title:node.text,   
                            //从URL读取远程数据并且显示到面板。
						    href:node.attributes.url,
						    closable:true,    
						    tools:[{    
						        iconCls:'icon-mini-refresh',    
						        handler:function(){    
						            alert('refresh');    
						        }    
						    }]    
						}); 
			    	}
				} 
			});
	}) 
</script>	
</body>
</html>

tabs标签添加href属性, 从URL读取远程数据并且显示到面板. 

- demo1.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">
<title>Insert title here</title>
</head>
<body>
	
<div id="p"></div>

<script type="text/javascript">
	$(function(){
		$('#p').panel({
			width:400,
			height:200,
			title:'Intel',
			content:'<h1>Intel</h1>'
		});
	});
</script>
</body>
</html>
  • demo1.jsp没有导入EasyUI的CSS和Javascript文件到当前页面

  • demo2.jsp

<div id="p1"></div>

<script type="text/javascript">
	$(function(){
		$('#p1').panel({
			width:400,
			height:200,
			title:'Java',
 			tools: [{    
			   iconCls:'icon-add',    
			   handler:function(){alert('new')}    
			   },{    
			   iconCls:'icon-save',    
			   handler:function(){alert('save')}    
			}], 
			content:'<h1>Java</h1>'
		});
	});
</script>
    • demo02.jsp甚至连jsp页面的属性也没有设置

    • demo01.jsp与demo02.jsp各自div中的id要设置成不同值.

  • 通过以上实验说明通过href属性加载的远程数据被聚合到treeAttributes.html中,作为该页面的一部分, 所以共用该页面导入的EasyUI的CSS和Javascript文件.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值