跟我一起学extjs5(05--主界面上增加顶部和底部区域)


        这一节为主界面加一个顶部区域和底部区域。

一个管理系统的界面能够粗分为顶部标题部分、中间数据展示和处理的部分、底部备注和状态部分。

        在添加这二个区域之前,我们先在MainModel.js中添加一些数据。
Ext.define('app.view.main.MainModel', {
extend : 'Ext.app.ViewModel', alias : 'viewmodel.main', data : {
name : 'app', // 系统信息
system : {
name : 'project项目合同及资金管理系统',
version : '5.2014.06.60',
iconUrl : ''
}, // 用户单位信息和用户信息
user : {
company : '武当太极公司',
department : 'project部',
name : '张三丰'
}, // 服务单位和服务人员信息
service : {
company : '无锡熙旺公司',
name : '蒋锋',
phonenumber : '1320528----',
qq : '78580822',
email : 'jfok1972@qq.com',
copyright : '熙旺公司'
}
}
// TODO - add data, formulas and/or methods to support your view
});

在上面的代码中,在data中添加了三个类型的数据。以下分别有些属性。这些值和属性以后能够从后台获得。比方说后台的系统名称改过了。前台刷新一下界面,就能展示新的system.name。

这也符合我这个系统的开发宗旨,能够动态的信息尽量动态化,改动的时候仅仅要在前台配置就能够,不要去改动后台的js或java代码。


        以下在main的文件夹下增加二个文件,分别为Top.js和Bottom.js。文件夹结构例如以下:


        Top.js定义了一个类,其类名为‘app.view.main.region.Top’,注意其类名的前面和其路径是一致的。

extjs的类载入机制就是依据类名来找到详细的类文件在哪里的。


/**
* 系统主页的顶部区域,主要放置系统名称,菜单,和一些快捷button
*/
Ext.define('app.view.main.region.Top', { extend : 'Ext.toolbar.Toolbar', alias : 'widget.maintop', // 定义了这个组件的xtype类型为maintop items : [{
xtype : 'image',
bind : { // 数据绑定到MainModel中data的ystem.iconUrl
hidden : '{!system.iconUrl}', // 假设system.iconUrl未设置,则此image不显示
src : '{system.iconUrl}' // 依据system.iconUrl的设置来载入图片
}
}, {
xtype : 'label',
bind : {
text : '{system.name}' // text值绑定到system.name
},
style : 'font-size : 20px; color : blue;'
}, {
xtype : 'label',
bind : {
text : '{system.version}'
}
}, '->', {
text : '菜单',
menu : [{
text : 'project管理',
menu : [{
text : 'project项目'
}, {
text : 'project标段'
}]
}]
}, ' ', ' ', {
text : '主页'
}, {
text : '帮助'
}, {
text : '关于'
}, {
text : '注销'
}, '->', '->', {
text : '设置'
}] });

上面是Top.js类的定义。这是一个toolbar控件,里面增加了一些label和Button,用于显示系统名称以及用来实现一些操作。toolbar的items下默认的xtype是Button。源码的凝视里面也写入了怎样绑定到MainModel 的数据的备注。

        以下是Button.js的代码:

/**
* 系统主页的底部区域,主要放置用户单位信息,服务单位和服务人员信息
*/
Ext.define('app.view.main.region.Bottom', { extend : 'Ext.toolbar.Toolbar', alias : 'widget.mainbottom', items : [{
bind : {
text : '使用单位:{user.name}'
}
}, {
bind : {
text : '用户:{user.name}'
}
}, '->', {
bind : {
text : '服务单位:{service.company}'
}
}, {
bind : {
text : '服务人员:{service.name}'
}
}, {
bind : {
text : 'tel:{service.phonenumber}'
}
}, {
bind : {
hidden : '{!service.email}', // 绑定值前面加! 表示取反。假设有email则不隐藏,假设email未设置,则隐藏
text : 'eMail:{service.email}'
}
}, {
bind : {
text : '©{service.copyright}'
}
}]
});

至此要增加的二个js文件已经就绪,如今我们要把他们放到Main的主页面之中。Main.js也须要改动一下,须要引入上面这二个类。以及把他们放到items下。并设置好位置。


/**
* This class is the main view for the application. It is specified in app.js as
* the "autoCreateViewport" property. That setting automatically applies the
* "viewport" plugin to promote that instance of this class to the body element.
*
* TODO - Replace this content of this view to suite the needs of your
* application.
*/
Ext.define('app.view.main.Main', {
extend : 'Ext.container.Container', xtype : 'app-main', uses : ['app.view.main.region.Top', 'app.view.main.region.Bottom'], controller : 'main',
// MVVM架构的控制器的名称。会在当前路径中依据‘Main’ + Controller 来确定文件名称
// 这个我没找到其它不论什么能够自己主动载入MainController.js的依据,仅仅能作上面的推断了
viewModel : {
type : 'main'
// MVVM架构的viewModel的类型,会在当前路径中依据‘Main’ + Model 来确定文件名称
}, layout : {
type : 'border' // 系统的主页面的布局
}, items : [{
xtype : 'maintop',
region : 'north' // 把他放在最顶上
}, {
xtype : 'mainbottom',
region : 'south' // 把他放在最底下
}, {
xtype : 'panel',
bind : {
title : '{name}'
},
region : 'west', // 左边面板
html : '<ul><li>This area is commonly used for navigation, for example, using a "tree" component.</li></ul>',
width : 250,
split : true,
tbar : [{
text : 'Button',
handler : 'onClickButton'
}]
}, {
region : 'center', // 中间面版
xtype : 'tabpanel',
items : [{
title : 'Tab 1',
html : '<h2>Content appropriate for the current navigation.</h2>'
}]
}]
});





        extjs中有很多布局。当中的一个border比較经常使用,他能够将items分成上、下、左、右、和中间五个部分。

经过上面几步以后,在浏览器刷新一下网页,会看到例如以下结果:


watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvamZvaw==/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/Center" alt="">



跟我一起学extjs5(05--主界面上增加顶部和底部区域)的更多相关文章

  1. 4、手把手教你Extjs5(四)主界面上加入顶部和底部区域

    这一节为主界面加一个顶部区域和底部区域.一个管理系统的界面可以粗分为顶部标题部分.中间数据展示和处理的部分.底部备注和状态部分. 在增加这二个区域之前,我们先在MainModel.js中加入一些数据. ...

  2. ExtJS5_主界面上加入顶部和底部区域

    为主界面加一个顶部区域和底部区域.一个管理系统的界面可以粗分为顶部标题部分.中间数据展示和处理的部分.底部备注和状态部分. 在增加这二个区域之前,我们先在MainModel.js中加入一些数据. Ex ...

  3. 跟我一起学extjs5(08--自己定义菜单1)

    跟我一起学extjs5(08--自己定义菜单1) 顶部和底部区域已经作好,在顶部区域有一个菜单的button.这一节我们设计一个菜单的数据结构,使其能够展示出不相同式的菜单.因为准备搭建的是一个系统模 ...

  4. (NO.00004)iOS实现打砖块游戏(二):实现游戏主界面动画

    大熊猫猪·侯佩原创或翻译作品.欢迎转载,转载请注明出处. 如果觉得写的不好请告诉我,如果觉得不错请多多支持点赞.谢谢! hopy ;) 一个内容不错的游戏也要一个好的包装.玩家进入游戏时第一眼看到的是 ...

  5. Android Tab类型主界面 Fragment+TabPageIndicator+ViewPager

    文章地址: Android项目Tab类型主界面大总结 Fragment+TabPageIndicator+ViewPager 1.使用ViewPager + PagerAdapter 每个页面的内容都 ...

  6. 国产网络损伤仪SandStorm -- 主界面简介

    国产网络损伤仪SandStorm可以模拟出带宽限制.时延.时延抖动.丢包.乱序.重复报文.误码.拥塞等网络状况,在实验室条件下准确可靠地测试出网络应用在真实网络环境中的性能,以帮助应用程序在上线部署前 ...

  7. C# 读取word2003 并且显示在界面上的方法

    1.新建一个windows窗体程序 2. 引入包WinWordControl.dll 3.添加引用 4.引入组件WinWordControl组件 5.主界面上加入按钮 ,opendialog, win ...

  8. 跟我一起学extjs5(13--运行菜单命令在tabPanel中显示模块)

    跟我一起学extjs5(13--运行菜单命令在tabPanel中显示模块)         上面设计好了一个模块的主界面,以下通过菜单命令的运行来把这个模块增加到主界面其中. 在MainModule. ...

  9. [课程设计]Scrum 1.3 多鱼点餐系统开发进度(系统主界面框架&美化)

    Scrum 1.3 多鱼点餐系统开发进度(系统主界面框架&美化) 1.团队名称:重案组 2.团队目标:长期经营,积累客户充分准备,伺机而行 3.团队口号:矢志不渝,追求完美 4.团队选题:餐厅 ...

随机推荐

  1. 四大主流云平台对比--CloudStack, Eucalyptus, vCloud Director和OpenStack。

    我迟早可能都要进入的领域,提前温习... 还有KVM,ESXI,API,XEN之间的术语和关系,也要心中有数.. ~~~~~~~~~~~~~~~~~~~ 云计算在如今的IT界一直是一个最热门的话题,鉴 ...

  2. http://blog.sina.com.cn/s/blog_7caae74b0100zl17.html

    http://blog.sina.com.cn/s/blog_7caae74b0100zl17.html

  3. SPRING IN ACTION 第4版笔记-第六章RENDERING WEB VIEWS-006- 使用thymeleaf(TemplateResolver、SpringTemplateEngine、ThymeleafViewResolver、th:include、th:object、th:field="*{firstName}")

    一.在Spring中使用thymeleaf的步骤 1.配置 In order to use Thymeleaf with Spring, you’ll need to configure three ...

  4. bulkTransfer通讯必须注意的问题:bulk buffer size(16K)

    Android USB host与HID使用bulkTransfer通讯接收和发送的数据长度不会超过16384,这个问题困扰了我很长一段时间,终于发现问题所在,不是出在我的程序设计,也不是硬件的发送/ ...

  5. Android EditText如何去除边框添加下划线

    (一)问题 之前的自定义EditText只能显示高度不超过屏幕高度的文本内容,继续增加内容会出现如下问题: (二)原因分析 下部(超出屏幕高度的部分)没有继续画线,也就是说横线没有画够,那么一定是循环 ...

  6. Android 图片从网页中获取并动态加载到listview中

    实现功能: 效果图: 代码:这里

  7. Python sh库学习 上篇

    官方文档有句话"allows you to call any program",并且:helps you write shell scripts in Python by givi ...

  8. Oracle Form属性、内置子程序、触发器、系统变量简要

    一.属性 1.1 通用属性 名称(Name) 子类信息(Subclass Information) 备注(Comments) 标题(Title) 方向(Direction) 字体名称(Font Nam ...

  9. 超大型 LED 显示屏

    http://acm.hunnu.edu.cn/online/?action=problem&type=show&id=11574&courseid=0 题目 E. 超大型 L ...

  10. 【转】Installing OpenCV on Debian Linux

    In this post I will describe the process of installing OpenCV(both versions 2.4.2 and 2.4.3) on Debi ...