標籤:style blog http 使用 io 資料 2014 cti
3.1 在上面顯示的頁面中,大家可以看到左邊的導航沒有菜單選項,因此就不夠名副其實了,下面我們添加樹形菜單
還是在視圖中建立Mymenutree.js,代碼如下:
store=Ext.create(‘Ext.data.TreeStore‘, {
defaultRoodId:‘root‘,
root: {
expanded: true,
children: [
{ text: "地面資料", expanded: true,
children: [
{ text: "降水", expanded: true,children:[
{ text: "1小時降水", leaf: true },
{ text: "3小時降水", leaf: true },
{ text: "6小時降水", leaf: true },
{ text: "12小時降水", leaf: true },
{ text: "24小時降水", leaf: true }
] },
{ text: "溫度", leaf: true},
{ text: "氣壓", leaf: true },
{ text: "日照", leaf: true }
] },
{ text: "高空資料", expanded: true,children:[
{ text: "GPS/MET", leaf: true },
{ text: "閃電定位", leaf: true },
{ text: "高空分析圖", leaf: true }
] },
{text:"農業和生態資料",expanded:true,children:[
{ text: "土壤水分資料", leaf: true },
{ text: "酸雨資料", leaf: true },
{ text: "凍土資料", leaf: true },
{ text: "生態環境資料", leaf: true }
]}
]
}
});
Ext.define(‘FLY.view.Mymenutree‘ ,{
extend: ‘Ext.tree.TreePanel‘,
alias: ‘widget.menutree‘,
border:false,
hrefTarget:‘mainContent‘,//修改的頁面顯示部分的id
store: store,
rootVisible: false,
bodystyle:{
background:‘#ffc‘,
padding:‘10px‘
}
});
因為資料比較少,所以我把store的部分放在了這裡,大家也可以分開放,這樣便於管理。
3.2 同樣需要在控制器controller中配置視圖才會生效。
Ext.define(‘FLY.controller.Mycontroller‘, {
extend: ‘Ext.app.Controller‘,
views: [
‘Mymenutree‘,‘Viewport‘//修改部分在此
],
//通過init函數來監聽視圖事件,控制視圖與控制器的互動
init:function(){
this.control({
‘menutree‘:{
itemclick:this.changePage
}
});
},
changePage:function(){
alert(‘success‘);//測試使用
}
});
這樣再次儲存代碼,發布到伺服器,顯示頁面如下:
本執行個體初見雛形,還需繼續修改,待續……