ExtJS MVC的搭建(三)

來源:互聯網
上載者:User

標籤: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‘);//測試使用
}
});

這樣再次儲存代碼,發布到伺服器,顯示頁面如下:

本執行個體初見雛形,還需繼續修改,待續……

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.