Card 卡片式佈局

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>卡片式佈局</title>
<link rel="stylesheet" href="ext-4.2.1/resources/css/ext-all.css" />
<script type="text/javascript" src="ext-4.2.1/bootstrap.js"></script>
<script type="text/javascript" src="ext-4.2.1/locale/ext-lang-zh_CN.js"></script>
<script type="text/javascript">
Ext.onReady(function(){
var testpanel=Ext.create('Ext.panel.Panel',{
layout:'card', //卡片式佈局
[color=red] activeItem:0, //設置默認顯示的第一個子面板[/color]
title:'Ext.layout.CardLayout',
frame:true,
renderTo:Ext.getBody(),
bodyPadding:5,
width:250,
height:150,
defaults:{
bodyStyle:'background-color:#FFFFFF'
},
//面板items配置項默認的xtype類型爲panel 該默認值可以通過defaultType配置項進行更改
items:[{
title:'嵌套面板一',
html:'說明一',
id:'p1'
},{
title:'嵌套面板二',
html:'說明二',
id:'p2'
},
{
title:'嵌套面板三',
html:'說明三',
id:'p3'
}],
buttons:[{
text:'上一頁',
handler:changePage
},{
text:'下一頁',
handler:changePage
}]
});
//切換子面板
function changePage(btn){
var index=Number(testpanel.layout.activeItem.id.substring(1));
if(btn.text=='上一頁'){
index-=1;
if(index<1){
index=1;
}
}else{
index+=1;
if(index>3){
index=3;
}
}
testpanel.layout.setActiveItem('p'+index);
}
});
</script>
//該佈局包含多個子面板,任何時候都只有一個子面板處於顯示狀態,這種佈局類經常用來製作嚮導和標籤頁。該佈局的重點方法是setActiveItem 。因爲一次只能顯示一個子面板,所以[color=red]切換頁面的唯一途徑就是setActiveItem方法[/color],它接受一個子面板id或索引作爲參數。
</head>

<body>

</body>
</html>
發佈了16 篇原創文章 · 獲贊 0 · 訪問量 2737
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章