zoukankan
html css js c++ java
ExtJS中如何扩展自定义的类
JS代码
1
/**/
/*
*
2
* ExtJs自定义PersonListGridPanel类
3
* 该类继承自GridPanel[使用Ext.extend(superClass,override Object)方法实现继承],
4
* 并override了该类的构造函数
5
* 构造函数内部继承自GridPanel的构造函数[apply(this,arguments)实现继承]
6
* 该类实现了如何对外部公布一个事件
7
* 在构造函数中添加一个事件[this.addEvents("事件名称")]
8
* 然后使用this.fireEvent("事件名称",参数)来发布此事件
9
* 最后在客户端调用的时候来订阅该事件
10
*/
11
PersonListGridPanel
=
Ext.extend(Ext.grid.GridPanel,
{
12
constructor:
function
(_url)
{
13
PersonListGridPanel.superclass.constructor.apply(
this
, [
{
14
renderTo: Ext.getBody(),
15
350
,
16
height:
200
,
17
frame:
true
,
18
layout:
"
form
"
,
19
tbar:[
{
20
text:
"
add
"
21
}
,
"
-
"
,
{
22
text:
"
update
"
23
}
,
"
-
"
,
{
24
text:
"
delete
"
25
}
],
26
enableColumnMove:
false
,
27
columns: [
{
28
header:
"
Name
"
,
29
menuDisabled:
true
,
30
dataIndex:
"
name
"
31
}
,
{
32
header:
"
Age
"
,
33
menuDisabled:
true
,
34
dataIndex:
"
age
"
35
}
,
{
36
header:
"
Sex
"
,
37
menuDisabled:
true
,
38
dataIndex:
"
sex
"
39
}
],
40
store:
new
Ext.data.JsonStore(
{
41
autoLoad:
true
,
42
url: _url,
43
fields: [
"
name
"
,
"
age
"
,
"
sex
"
]
44
}
),
45
46
selModel:
new
Ext.grid.RowSelectionModel(
{
47
singleSelect:
true
,
48
listeners:
{
49
"
rowselect
"
:
{
50
fn:
function
(_sel, _index, _r)
{
51
this
.fireEvent(
"
rowselect
"
, _r);
//
发布事件
52
}
,
53
scope:
this
54
}
55
}
56
}
)
57
58
}
]);
59
this
.addEvents(
"
rowselect
"
);
//
添加事件
60
}
61
}
)
62
前端调用代码
1
/**/
/*
*
2
* 前端调用自定义类(组件)
3
*/
4
Ext.onReady(
function
()
{
5
var
_grid
=
new
PersonListGridPanel(
"
http://localhost:3830/extjs/gridData.ashx
"
);
6
//
以下订阅该事件
7
_grid.on(
"
rowselect
"
,
function
(_r)
{
8
this
.getForm().loadRecord(_r);
9
}
,_form);
10
11
}
);
查看全文
相关阅读:
ubuntu12.04 安装完XRDP显示空白桌面
安装完CUDA Toolkit,VS2010调试项目控制台一闪而过
控制台连接oracle11g报ORA-12560异常
@Autowired和@Resource
@Autowire和@Resource区别
springMVC
springmvc常用注解标签详解
Spring/SpringMvc 配置文件常用标签解释
java中volatile不能保证线程安全(实例讲解)
volatile关键字解析
原文地址:https://www.cnblogs.com/xnxylf/p/1427243.html
最新文章
Jmeter接口测试①——POST请求
基础命令(一)
压缩和解压缩
用户组管理
用户与用户管理
linux的运行模式
扩展功能(重要)
实用的功能
linux中终端字体样式显示不正常
末行模式和编辑模式
热门文章
vim总结
rabbitmq安装
微服务架构初识
编译Linux
WCF 异常 The server was unable to process the request due to an internal error.
docker image ubuntu12.04 安装软件源
Ubuntu14.04 无法关机 SpamAssassin speech-dispatcher
ubuntu12.04安装JDK8
ubuntu12.04 eclipse安装PyDev
windows7配置C++编译环境
Copyright © 2011-2022 走看看