只是在頁面中演示tree的使用,寫死在頁面中,未從數據庫中調用數據
<script type="text/javascript">
Ext.onReady(function() {
var tree = Ext.create('Ext.tree.Panel', {
title : '樹面板簡單示例',//標題
width : 200,
height : 500,
rootVisible: true,//是否顯示root
renderTo : Ext.getBody(),
root :
{
text : '樹根',//節點名稱
expanded : true,//默認展開根節點
//創建子節點
children :
[
//第一個子節點
{
text : '節點1',//節點名稱
leaf : false,//說明不是葉子節點,可以加子節點
children :
{
text : '節點1',//節點名稱
leaf : true,//說明為葉子節點,后面不再有子節點
}
},
//第二個子節點
{
text : '節點2',//節點名稱
leaf : true,//說明為葉子節點
}
]
}
});
});
</script>
效果圖
多列樹
<script type="text/javascript">
Ext.onReady(function() {
var tree = Ext.create('Ext.tree.Panel', {
title : '樹面板簡單示例',//標題
width : 300,
height : 500,
rootVisible: true,//是否顯示root
fields : ['text','description'],
columns :
[
{
xtype: 'treecolumn',//樹狀表格列
text: '名稱',
dataIndex: 'text', //設置顯示的名稱
width: 150,
sortable: true
},
{
text: '描述',
dataIndex: 'description',
flex: 1,
sortable: true
}
],
renderTo : Ext.getBody(),
root :
{
text : '樹根',//節點名稱
description : '根目錄',
expanded : true,//默認展開根節點
//創建子節點
children :
[
//第一個子節點
{
text : '節點1',//節點名稱
description : '第一個節點',
leaf : false,//說明不是葉子節點,可以加子節點
children :
{
text : '節點1的節點',//節點名稱
description : '第一個節點的節點',
leaf : true,//說明為葉子節點,后面不再有子節點
}
},
//第二個子節點
{
text : '節點2',//節點名稱
description : '第二個節點',
leaf : true,//說明為葉子節點
}
]
}
});
});
</script>
效果圖
更多文章、技術交流、商務合作、聯系博主
微信掃碼或搜索:z360901061
微信掃一掃加我為好友
QQ號聯系: 360901061
您的支持是博主寫作最大的動力,如果您喜歡我的文章,感覺我的文章對您有幫助,請用微信掃描下面二維碼支持博主2元、5元、10元、20元等您想捐的金額吧,狠狠點擊下面給點支持吧,站長非常感激您!手機微信長按不能支付解決辦法:請將微信支付二維碼保存到相冊,切換到微信,然后點擊微信右上角掃一掃功能,選擇支付二維碼完成支付。
【本文對您有幫助就好】元

