ext--tablepanel

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <title>tabpanel.html</title>
	
    <meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
    <meta http-equiv="description" content="this is my page">
    <meta http-equiv="content-type" content="text/html; charset=UTF-8">
    
    <link rel="stylesheet" type="text/css" href="../ext/resources/css/ext-all.css">
	<script type="text/javascript" src="../ext/adapter/ext/ext-base.js"></script>
	<script type="text/javascript" src="../ext/ext-all.js"></script>
	<script type="text/javascript">
		Ext.onReady(function(){
			var tabPanel = new Ext.TabPanel(
				{
				activeTab:0,//激活的Tab
				width:document.body.clientWidth,
				height:document.body.clientHeight,
				closable : true,
				autoDestroy:true,
				items:[
					{title:"标签1",html:"<b>标签1</b>",bodyStyle:"padding:10px"},//内容是写死的。
					{title:"标签2",autoLoad:{url:"../index.jsp"}},//加载一个页面
					{title:"标签3",contentEl:"div1"},
					{title:"标签4",html:"<b>标签4</b>"},
					{title:"标签5",html:"<b>标签5</b>"}
				],
				renderTo:"tab",
				defaults:{autoScroll:true},
				enableTabScroll:true,//内容超过了出现滚动条
				border:true,//边框。
				frame:true
				}
			);
			
			Ext.get("btn1").on("click",function(){
				var activeTab = tabPanel.getActiveTab();
				tabPanel.items.each(function(item){
					alert(item);
					if (item.closable && item != activeTab){
						tabPanel.remove(item);
					}
				});
			});
			
			Ext.get("btn2").on("click",function(){
				tabPanel.items.each(function(item){
					if (item.closable){
						tabPanel.remove(item);
					}
				});
			});
			var i = 6;
			//  添加标签
			Ext.get("btn3").on("click",function(){
				var tabpanel = new Ext.TabPanel(
					{
						title:"TabPanel" + i,
						html:"TabPanel" + i
					}
				);
				tabPanel.add(tabpanel); // 添加标签
				tabPanel.setActiveTab(tabpanel); // 激活
				i++;
			});
			
			//  删除标签
			Ext.get("btn4").on("click",function(){
				var currentTab = tabPanel.getActiveTab();
				tabPanel.remove(currentTab); // 删除标签
			});
		});
	</script>
  </head>
  
  <body>
    	<div id="tab"></div>
    	<br>
    	<input type="button" id="btn1" value="删除所有非活动标签">
    	<input type="button" id="btn2" value="删除所有标签">
    	<input type="button" id="btn3" value="添加标签">
    	<input type="button" id="btn4" value="删除标签">
  </body>
</html>



你可能感兴趣的:(ext)