本文地址:http://blog.csdn.net/sushengmiyan/article/details/39102335

官方例子:http://dev.sencha.com/ext/5.0.1/examples/window/layout.html?theme=neptune

本文作者:sushengmiyan

------------------------------------------------------------------------------------------------------------------------------------

做一个系统的话,一般都需要有导航栏啊,工具条啊这些东西。看到Ext官方例子中有个window的layout window ,看了下效果看起来蛮不错,就学习了下,加入到了我之前做的extjs5登录系统中。这样看起来就像是一个系统了。

先看下官方例子的效果吧,看起来很不错的哟:

看下官方给的代码:

代码地址:http://dev.sencha.com/ext/5.0.1/examples/window/layout.js

代码内容:

Ext.require([
'Ext.tab.*',
'Ext.window.*',
'Ext.tip.*',
'Ext.layout.container.Border'
]);
Ext.onReady(function(){
var win,
button = Ext.get('show-btn'); button.on('click', function(){ if (!win) {
win = Ext.create('widget.window', {
title: 'Layout Window with title <em>after</em> tools',
header: {
titlePosition: 2,
titleAlign: 'center'
},
closable: true,
closeAction: 'hide',
maximizable: true,
animateTarget: button,
width: 600,
minWidth: 350,
height: 350,
tools: [{type: 'pin'}],
layout: {
type: 'border',
padding: 5
},
items: [{
region: 'west',
title: 'Navigation',
width: 200,
split: true,
collapsible: true,
floatable: false
}, {
region: 'center',
xtype: 'tabpanel',
items: [{
// LTR even when example is RTL so that the code can be read
rtl: false,
title: 'Bogus Tab',
html: '<p>Window configured with:</p><pre style="margin-left:20px"><code>header: {\n titlePosition: 2,\n titleAlign: "center"\n},\nmaximizable: true,\ntools: [{type: "pin"}],\nclosable: true</code></pre>'
}, {
title: 'Another Tab',
html: 'Hello world 2'
}, {
title: 'Closable Tab',
html: 'Hello world 3',
closable: true
}]
}]
});
}
button.dom.disabled = true;
if (win.isVisible()) {
win.hide(this, function() {
button.dom.disabled = false;
});
} else {
win.show(this, function() {
button.dom.disabled = false;
});
}
});
});

现在看看我的最后成果:

看起来是不是跟官方的差不多呀,哈哈。这就是模仿咯,能知道如何看官方的例子了,感觉就来啦,可以顺利上手的样子了。

哈哈。

看看需要做哪些就可以达到如上效果吧!

1.增加菜单项的内容,就是 学生档案、教室档案那些,这个我们暂时放在mainmodel下的data里面,这个自己制定,可以直接在panel的items定死也是可以的,这里动态获取一下。

/**
* 应用程序主要视图.author: sushengmiyan
*blog: http://blog.csdn.net/column/details/sushengextjs5.html
*/
Ext.define('oaSystem.view.main.MainModel', {
extend: 'Ext.app.ViewModel',
alias: 'viewmodel.main',
//数据模块 ViewModel中的data可以在指定当前ViewModel的地方获取
data: {
name: 'oaSystem',
// 左边菜单的加载
NavigationMenu : [{
text : '档案管理',// 菜单项的名称
description : '', // 菜单项的描述
expanded : true,// 在树形菜单中是否展开
items : [{
text : '学生档案',// 菜单条的名称
module : 'StudentArchives',// 对应模块的名称
glyph : 0xf00b // 菜单条的图标字体
},{
text : '教师档案',
module : 'TeacherArchives',
glyph : 0xf1a2
},{
text : '教室资源',
module : 'RoomArchives',
glyph : 0xf183
}]
},{
text : '系统设置',
description : '',
items : [{
text : '系统参数',
module : 'SytemInfo',
glyph : 0xf0f7
}, {
text : '高级设置',
module : 'HigherSetting',
glyph : 0xf02e
}]
} ]
}, //增加 data, formulas and/or methods 来支持你的视图
});

在regions目录下新建Left.js内容如下:

Ext.define(
//左侧导航条
'oaSystem.view.main.region.Left',
{
extend: 'Ext.panel.Panel',
alias: 'widget.mainleft',
title: '折叠菜单',
glyph: 0xf0c9,
split: true,
collapsible: true,
floatable: false,
tools: [{type: 'pin'}],
header: {
titlePosition: 2,
titleAlign: 'center'
},
maximizable: true,
layout: {
type: 'accordion',
animate: true, //点击的时候有动画动作
titleCollapse: true,
enableSplitters: true,
hideCollapseTool: true,
}, viewModel: 'main', //指定后可获取MainModel中data数据块 initComponent: function() {
this.items = [];
var menus = this.getViewModel().get('NavigationMenu');
for (var i in menus) {
//先获取分组显示
var group = menus[i];
var leftpanel = {
menuAccordion : true,
xtype: 'panel',
title: group.text,
bodyStyle: {
padding: '10px'
},
layout: 'fit',
dockedItems: [{
dock : 'left',
xtype : 'toolbar',
items : []
}],
glyph: group.glyph
};
//遍历分组下的菜单项
for (var j in group.items) {
var menumodule = group.items[j];
leftpanel.dockedItems[0].items.push({
text: menumodule.text,
glyph: menumodule.glyph,
handler: 'onMainMenuClick'
});
}
this.items.push(leftpanel);
}
this.callParent(arguments);
},
} );

在main.js中引入这个单元:

uses:['oaSystem.view.main.region.Top', 'oaSystem.view.main.region.Bottom','oaSystem.view.main.region.Left'],

在items中增加这个折叠导航:

,{
xtype : 'mainleft',
region : 'west', // 左边面板
width : 250,
split : true
}

OK,完工。现在就可以有个折叠导航啦

[ExtJS5学习笔记]第十七节 Extjs5的panel组件增加accodion成为折叠导航栏的更多相关文章

  1. [ExtJS5学习笔记]第二十七节 CMD打包错误 Error C2009: YUI Parse Error (identifier is a reserved word => debugger;)

    本文地址:http://blog.csdn.net/sushengmiyan/article/details/41242993 本文作者:sushengmiyan ------------------ ...

  2. [ExtJS5学习笔记]第二十七节 CMD打包错误 Error C2009: YUI Parse Error (identifier is a reserved word =&gt; debugger;)

    本文地址:http://blog.csdn.net/sushengmiyan/article/details/41242993 本文作者:sushengmiyan ------------------ ...

  3. [ExtJS5学习笔记]第二十一节 Extjs5中使用config配置给ext.widget或者create方法传递参数

    本文地址:http://blog.csdn.net/sushengmiyan/article/details/39252805 官方例子:http://docs.sencha.com/extjs/5. ...

  4. [ExtJS5学习笔记]第十节 Extjs5新增特性之ViewModel和DataBinding

    本文地址:http://blog.csdn.net/sushengmiyan/article/details/38612721 本文作者:sushengmiyan ------------------ ...

  5. [ExtJS5学习笔记]第二十节 Extjs5配合数组的push方法,动态创建并加载组件

    本文地址:http://blog.csdn.net/sushengmiyan/article/details/39226773 官方例子:http://docs.sencha.com/extjs/5. ...

  6. [ExtJS5学习笔记]第七节 Extjs5的组件components及其模板事件方法学习

    本文地址:http://blog.csdn.net/sushengmiyan/article/details/38487519 本文作者:sushengmiyan ------------------ ...

  7. [ExtJS5学习笔记]第四节 欢迎来到extjs5-手把手教你实现你的第一个应用

    本文地址:http://blog.csdn.net/sushengmiyan/article/details/38331347 本文作者:sushengmiyan ------------------ ...

  8. [ExtJS5学习笔记]第五节 使用fontawesome给你的extjs5应用增加字体图标

    本文地址:http://blog.csdn.net/sushengmiyan/article/details/38458411本文作者:sushengmiyan-------------------- ...

  9. [ExtJS5学习笔记]第五节 使用fontawesome给你的extjs5应用添加字体图标

    本文地址:http://blog.csdn.net/sushengmiyan/article/details/38458411本文作者:sushengmiyan-------------------- ...

随机推荐

  1. [Codeforces]856E - Satellites

    传送门 做法:每个卫星分别用连到左边圆与x轴交点的线的斜率和连到右边交点的线旋转90度的斜率可以表示成一个区间,问题转化成支持加/删区间和询问其中两个区间是否有交以及它们的交是否被其他区间包含.我一开 ...

  2. ●POJ 3348 Cows

    题链: http://poj.org/problem?id=3348 题解: 计算几何,凸包,多边形面积 好吧,就是个裸题,没什么可讲的. 代码: #include<cmath> #inc ...

  3. 计蒜客NOIP2017提高组模拟赛(四)day1

    T1:小X的质数 小 X 是一位热爱数学的男孩子,在茫茫的数字中,他对质数更有一种独特的情感.小 X 认为,质数是一切自然数起源的地方. 在小 X 的认知里,质数是除了本身和 1 以外,没有其他因数的 ...

  4. [Codeforces]663E Binary Table

    某变换好题.不过听说还有O(2^n*n^2)DP的…… Description 给定一个n*m的01矩阵,你可以选择对任意行和任意列取反,使得最终“1”的数量尽量少. Input 第一行两个整数n,m ...

  5. HDU 6107 Typesetting

    Problem Description Yellowstar is writing an article that contains N words and 1 picture, and the i- ...

  6. Codeforces #Round 785(Div.2)

    假的div2 C题没事写什么公式被卡精度了,掉分了gg --------------------------------------------------- A....几个每个字符串预先给好一个代表 ...

  7. C语言如何输出%

    两个%即可,C语言中%有两个作用: 第一种是作为运算符,取余,例如:9%4=1(9/4=2--1). 第二种是转义符,比如在scanf()和printf()中的输入参数常出现带有%的表示参数类型的变量 ...

  8. java 第三次作业

    (一)学习总结 1.阅读下面程序,分析是否能编译通过?如果不能,说明原因.应该如何修改?程序的运行结果是什么?为什么子类的构造方法在运行之前,必须调用父 类的构造方法?能不能反过来? class Gr ...

  9. JQuery插件的写法和规范

    首先,在具体说明编写插件之前,我们先假定一个使用场景:有一个HTML页面(或.aspx页面),页面上放置了一个5行3列的表格,即:<table></table>标记,具体代码如 ...

  10. window 2008 下 安装域管理并且控制禁用QQ和U盘

    场景需求下: 需求一:禁止普通用户使用USB.CD-ROM等驱动器防止病毒和资料外泄  需求二:并USB 键盘鼠标要可以使用 三:限制qq聊天工具的使用.这是公司真实环境需求.因此需要先模拟测试一下, ...