Ext 常用组件解析

Panel

定义&常用属性

	//1.使用initComponent
Ext.define('MySecurity.view.resource.ResourcePanel', {
extend: 'Ext.panel.Panel',
requires:[
'MySecurity.view.resource.ResourceGrid'
],
xtype: 'resourcePanel',
//是否显示边框
border:true,
padding:'0 5',
//折叠模式
collapseMode:'header',
//是否可折叠
collapsible: true,
//点击header可折叠
titleCollapse:true,
//折叠的位置
collapseDirection : 'top',
//展开时header的位置
headerPosition:'left',
//是否隐藏header
hideHeaders: true, initComponent : function() {
this.grid = Ext.create('MySecurity.view.resource.ResourceGrid');
this.items = [this.grid];
this.callParent(arguments);
}
}); //2.使用items
Ext.define('MySecurity.view.resource.ResourcePanel', {
extend: 'Ext.panel.Panel',
requires:[
'MySecurity.view.resource.ResourceGrid'
],
xtype: 'resourcePanel',
border:true,
padding:'0 5',
items:[{
xtype:'resourceGrid'
}]
});

为panel添加click事件

	listeners:
{
'render': function(panel) {
panel.ariaEl.on('click', function(e,target) {
//do something
},panel);
}
}

Grid

定义&常用属性

	Ext.define('MySecurity.view.role.RoleGrid', {
extend: 'Ext.grid.Panel',
requires:[
'MySecurity.store.role.RoleStore',
'MySecurity.view.role.AddRoleWindow',
'MySecurity.view.role.AddResourceToRoleWindow'
],
xtype: 'roleGrid',
//标题
title:'角色',
//gridview设置
viewConfig:{
//是否允许选中表格的数据(供拷贝)
enableTextSelection:true
},
//添加插件
plugins: [{
//折叠表格插件
ptype: 'rowexpander',
rowBodyTpl : app.templates.roleTpl()
}],
initComponent : function() {
var me = this;
//定义列
me.columns = [{
//actioncolumn 用来返回一个带图标的按钮通过getClass方法可以定制显示
xtype:'actioncolumn',text:'修改',align:'center',width:50,
items: [{
iconCls: 'x-fa fa-pencil-square-o', handler: 'editRoleClick',scope:me
},{ //根据数据动态改变图标
getClass: function(v, metadata, record) {
if(record.get('status')=='P' && record.get('verified') )
return 'icon-hide'
else
return 'icon-other'
},
scope: me,
handler: me.deletePerform
}]
},
{
//表头
text: '日期',
//自动换行
cellWrap: true,
xtype: 'datecolumn'
dataIndex: 'name' ,
//拉伸比例
flex:1,
//格式化日期显示
format:'M j, Y',
//是否显示表头的菜单栏
menuDisabled: true,
//是否可以拉表头的位置
draggable: false,
//是否可以拉伸列框
resizable: false,
//是否可以点击表头排序
sortable: false
},
{
text: '描述', dataIndex: 'description',flex:1 ,
//显示内容的渲染器
renderer: function(value, meta, record){
if (!value) return '';
var img = '<img src="./images/right.png">';
return img;
}
}]; //添加分页组件
this.dockedItems = [{
xtype: 'pagingtoolbar',
store: this.store,
dock: 'bottom',
displayInfo: true
}]; //添加 top bur
this.tbar = [{
type: 'button', text: '添加角色' ,
iconCls:'x-fa fa-plus-circle',
handler:me.addRoleClick,scope:me
},{
type: 'button', text: '修改角色资源' ,
iconCls:'x-fa fa-plus-circle',
handler:me.updateResourcesToRoleClick,scope:me
}]; this.store = Ext.create('MySecurity.store.role.RoleStore'); this.callParent(arguments);
}
//省略其他方法
});

分组:

1.开启分组功能(改变分组header显示)

	//开启分组功能
this.features = [{
//grouping 为 Ext.enums.Feature 的一种
ftype: 'grouping',
groupHeaderTpl: '{name}',
hideGroupedHeader: true ,
enableGroupingMenu: false //是否开启改变分组菜单
}]; //改变分组header显示:
this.features = [{
ftype: 'grouping',
groupHeaderTpl: Ext.create('Ext.XTemplate',
'<div>{children:this.formatName}</div>',
{
formatName: function(children) {
if(!children.length) return '';
var firstchild = children[0];
return firstchild.data.hierachyName;
}
}
)
}];

2.store设定分组字段

	groupField: '分组字段'

编辑:

1.设置编辑的插件

	this.plugins = [
Ext.create('Ext.grid.plugin.CellEditing', {
clicksToEdit: 1
})
];

2.设置editor

	{
text: 'number',
dataIndex: 'number'
name:'baseline',
editor: {
xtype: 'numberfield',
allowBlank:false,
maxValue:100,
minValue:0
}
}

3.重新设置editor

	使用beforecellclick事件,使用setEditor() 重新设置editor
this.on('beforecellclick', this.onBeforeCellclick, this); onBeforeCellclick: function(self, td, cellIndex, record, tr) {
var baseline = this.down('[name ="baseline"]')
var isAllowDecimals = (record.get('kind') == 1);
baseline.setEditor({
xtype: 'numberfield',
allowBlank:false,
allowDecimals : isAllowDecimals,
allowExponential:isAllowDecimals
}); }

4.编辑事件

	this.on('edit', this.onEdit, this); 

    onEdit: function(editor, context) {

	}

行号/rownumberer:

	{
xtype: 'rownumberer',
text: '#',
renderer: function(value, meta, record, rowIndex ){
return '<div class="my-row-number">' + rowIndex + '</div>';
}
}

选择记录:

1.selModel

	this.selctionModel = Ext.create('Ext.selection.CheckboxModel',{
mode : "SINGLE"
})
this.selModel = this.selctionModel; 获取选中的record
this.selctionModel.getSelection();

2.checkcolumn

	{
xtype : 'checkcolumn',
dataIndex : 'selectedForName',
listeners:{
checkchange:'onCheckChange',
beforecheckchange:'beforeCheckedChange'
}
}

3.选中第一条record

    var selectionModel = this.getSelectionModel();

    if (this.store.getCount()) {
selectionModel.selectRange(0, 0);
};

改变行高度:

    .x-grid-row{
line-height: 5px;
}

Ext.tree.Panel

定义&属性

	this.tree = Ext.create('Ext.tree.Panel', {
flex: 1,
store: Ext.create('MySecurity.store.MyTreeStore'),
//隐藏根节点
rootVisible: false,
columns: [{
//树节点
xtype: 'treecolumn',
flex: 1,
menuDisabled: true,
cellWrap:true,
draggable: false,
resizable: false,
sortable: false,
minWidth: 200,
text: 'name',
dataIndex: 'name',
renderer: function(value, meta, record){
//if (record.get('leaf')) meta.tdCls = 'hide-column';
return value;
}
}, {
flex: 1,
text:'model',
dataIndex: 'model'
}, {
minWidth: 120,
text:'number',
dataIndex: 'number'
}]
});
//数据加载完成的操作
this.tree.store.on('load', this.onTreeStoreLoad, this);

Store & 数据实例

	//继承Ext.data.TreeStore
Ext.define('MySecurity.store.MyTreeStore', {
extend: 'Ext.data.TreeStore',
model: 'MySecurity.model.tree.MyTreeModel',
proxy: {
type: 'ajax',
url: '../controller/getTree'
},
autoLoad: true
}); //继承TreeModel
Ext.define('MySecurity.model.tree.MyTreeModel', {
extend: 'Ext.data.TreeModel',
fields: [{
name: 'name',
type: 'string'
}, {
name: 'model',
type: 'string'
}, {
name: 'bumber',
type: 'string'
}]
}); //data
{
"text": "1",
"children": [{
"name": "tree1",
"children": [{
"name": "node",
"number": 8,
"children": [{
"model": "model1",
"number": "4",
"leaf": true
},
{
"model": "model2",
"number": "4",
"leaf": true
}]
}]
},
{
"name": "tree2",
"children": [{
"name": "node",
"number": 8,
"children": [{
"model": "model13",
"number": "4",
"leaf": true
},
{
"model": "model133434",
"number": "4",
"leaf": true
}]
}]
}]
}

Ext.window.Window

	Ext.define('MySecurity.view.RoleWindow', {
extend: 'Ext.window.Window',
width: 400,
height: 160,
//关闭时隐藏
closeAction: 'hide',
//置顶窗口,不能编辑其他组件
modal: true,
layout: 'fit',
//标题
title:'RoleWindow',
initComponent : function() {
this.items =[{html:'test'}];
this.buttons = [{
xtype: 'button',
text: 'Upload',
cls: 'white-btn',
handler: this.onUploadBtnClick,
iconCls: 'btn-iconfont iconfont-upload',
scope: this
}];
this.callParent(arguments);
}
}); var myWindow = Ext.create('MySecurity.view.RoleWindow');
myWindow.show()
myWindow.close();

Ext.window.Toast(消息提示)

	Ext.toast(message, title, align, iconCls);

Ext.LoadMask(loading遮罩)

	var myPanel = new Ext.panel.Panel({
renderTo : document.body,
height : 100,
width : 200,
title : 'Foo'
}); var myMask = new Ext.LoadMask({
msg : 'Please wait...',
target : myPanel
}); myMask.show();
myMask.hide();

Ext 常用组件解析的更多相关文章

  1. Ionic 常用组件解析

    Ionic 常用组件解析 $ionicModal(弹出窗口): //创建一个窗口 //此处注意目录的起始位置为app $ionicModal.fromTemplateUrl('app/security ...

  2. Python常用组件、命令大总结(持续更新)

    Python开发常用组件.命令(干货) 持续更新中-关注公众号"轻松学编程"了解更多. 1.生成6位数字随机验证码 import random import string def ...

  3. .NetCore中的日志(1)日志组件解析

    .NetCore中的日志(1)日志组件解析 0x00 问题的产生 日志记录功能在开发中很常用,可以记录程序运行的细节,也可以记录用户的行为.在之前开发时我一般都是用自己写的小工具来记录日志,输出目标包 ...

  4. Android常用组件

    UI相关 图片 Android-Universal-Image-Loader:com.nostra13.universalimageloader:异步加载.缓存.显示图片 ImageLoader:co ...

  5. Android常用组件【转】

    UI相关 图片 Android-Universal-Image-Loader:com.nostra13.universalimageloader:异步加载.缓存.显示图片 ImageLoader:co ...

  6. 最全面 Nginx 入门教程 + 常用配置解析

    转自 http://blog.csdn.net/shootyou/article/details/6093562 Nginx介绍和安装 一个简单的配置文件 模块介绍 常用场景配置 进阶内容 参考资料 ...

  7. Ext常用开发基础知识

    Ext常用开发基础知识 组件定义 //这种方法可以缓存所需要的组件 调用起来比较方便(方法一 ) Ext.define('MySecurity.view.home.HomePanel', { //添加 ...

  8. 【转】【Nginx】Nginx 入门教程 + 常用配置解析

    == Nginx介绍和安装 == Nginx是一个自由.开源.高性能及轻量级的HTTP服务器及反转代理服务器, 其性能与IMAP/POP3代理服务器相当.Nginx以其高性能.稳定.功能丰富.配置简单 ...

  9. android开发常用组件【持续更新中。。。】

    UI相关 图片 Android-Universal-Image-Loader:com.nostra13.universalimageloader:异步加载.缓存.显示图片 ImageLoader:co ...

随机推荐

  1. SqlSessionFactoryBuilder、SqlSessionFactory、SqlSession作用域(Scope)和生命周期

    可以说每个MyBatis都是以一个SqlSessionFactory实例为中心的.SqlSessionFactory实例可以通过SqlSessionFactoryBuilder来构建.一是可以通过XM ...

  2. liunx命令1

    单词整理 terminal:终端 network-scripts:网络脚本 passwd:密码文件 nologin:禁止登陆 shutdown:关机 reboot:重启 poweroff:关机 gre ...

  3. 使用IDEA部署Myeclipse项目

    IDEA的下载和FREE注册 IDEA 下载地址:IDEA最新版本下载地址 IDEA 注册方法:注册方法 导入Myeclipse项目 IDEA主界面,选择Open,如下图所示 选择Myeclipse项 ...

  4. Javascript版-显示相应图片的详细信息

    Hi All, 分享一个通过JS来显示相应图片的详细信息. 需求:进入页面时,动态加载图片信息:当鼠标移动到某一图片上时,则显示该图片的大图片并显示相应说明信息:当鼠标移开图片时,清除新创建的元素. ...

  5. javaSE_07Java中类和对象-封装特性

    一.谈谈什么是面向对象的思维 理解面向对象,重点是要思考以下的问题 面向过程 vs 面向对象 Ø 谈谈什么是面向过程的编程思想? Ø 为什么有面向过程还要有面向对象? Ø 谈谈什么是面向对象的编程思想 ...

  6. 3.Node.js 自定义微信菜单

    文章目录:         1.Node.js 接入微信公众平台开发         2.Node.js access_token的获取.存储及更新         3.Node.js 自定义微信菜单 ...

  7. Vue.js 运行环境搭建详解(基于windows的手把手安装教学)及vue、node基础知识普及

    Vue.js 是一套构建用户界面的渐进式框架.他自身不是一个全能框架——只聚焦于视图层.因此它非常容易学习,非常容易与其它库或已有项目整合.在与相关工具和支持库一起使用时,Vue.js 也能完美地驱动 ...

  8. (转)Javascript的DOM操作 - 性能优化

    转载:https://my.oschina.net/blogshi/blog/198910 摘要: 想稍微系统的说说对于DOM的操作,把Javascript和jQuery常用操作DOM的内容归纳成思维 ...

  9. vijos1325 桐桐的糖果计划

    Description 桐桐是一个快乐的小朋友,他生活中有许多许多好玩的事,让我们一起来看看吧-- 桐桐很喜欢吃棒棒糖.他家处在一大堆糖果店的附近. 但是,他们家的区域经常出现塞车.塞人等情况,这导致 ...

  10. Python原理 -- 内存管理

    语言的内存管理是语言设计的一个重要方面. 它是决定语言性能的重要因素. 无论是 c语言 的手工管理, 还是 Java 的垃圾回收, 都成为语言最重要的特种. 以下以 python 为例, 说明一门动态 ...