ExtJS MVC的搭建(二)

來源:互聯網
上載者:User

標籤:style   blog   http   使用   io   資料   for   2014   

2.1要搭建一個MIS系統首先需要構建系統架構,建立架構視圖viewport.js,代碼如下所示:

     

Ext.define(‘FLY.view.Viewport‘,{
extend:‘Ext.container.Viewport‘,
layout:‘border‘,
items: [{
region: ‘north‘,
xtype:‘image‘,
src:‘image/bj2.png‘,
height:100
}, {
region: ‘west‘,
collapsible: true,
title: ‘資料導航‘,
width:180,
items:[{
xtype:‘menutree‘   //此處的‘menutree’為菜單面板視圖的別名
}]
}, {
region: ‘east‘,
title: ‘摘要資料‘,
collapsible: true,
split: true,
width: 150
}, {
region: ‘center‘,
id:‘mainContent‘,
xtype: ‘panel‘,
items:[{xtype:‘toolbar‘,
items:[
{xtype:‘datefield‘,
fieldLabel: ‘時間‘,
labelWidth:40,
width:140,
maxValue: new Date(),
format: ‘Y-m-d‘,
editable:false,
value: new Date().getDate()-1
},
{xtype:‘label‘,
text:‘站號‘},
{xtype:‘textfield‘},
{xtype:‘button‘,
text:‘查詢‘}]
}
]

},
{
region: ‘south‘,
xtype:‘toolbar‘,
padding:10,
items:[{xtype:‘label‘,
html: "<a href=‘#‘ onclick=‘aboutUs()‘ style=‘text-decoration:none;‘>關於我們</a>"  //此處的單機滑鼠監聽事件還需要在後面添加aboutUs函數才能響應
},‘-‘,‘-‘,
{xtype:‘label‘,
text:‘Copyright ©fly.cn. All Rights Reserved.‘
}]
}
]
});

2.2添加視圖以後,還需要在控制器裡進行配置才會生效

Ext.define(‘FLY.controller.Mycontroller‘, {
extend: ‘Ext.app.Controller‘,

views: [
‘Viewport‘          //在此處添加視圖
],
//通過init函數來監聽視圖事件,控制視圖與控制器的互動
init:function(){

this.control({

‘menutree‘:{
itemclick:this.changePage
}
});
},
changePage:function(){

alert(‘success‘);//測試使用
}
});

代碼寫完後,發布到tomcat伺服器上,效果如下

 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.