也学extjs 2
1.我想让加载后,按钮可用
[[[[[[createViewPort之后
var w=Ext.create("bfr.view.le.le.userList",config);
var btn=w.down("button[action=add]");
if (btn!=null){
btn.enable();
}
2.我想为按钮,动态添加事件.
[[[执行一次,添加一次,添加多次时,点击按钮时会执行多次]]]
this.control({ 'userList button[action=cancel]':{
click:this.doAdd
}});
3.我想为按钮,去掉已添加的事件
???
4.我想点击按钮时,打开新窗体
[[[[[先通过application.controllers获取要打开的窗体对应的controller,然后调用它的createViewPort方法)
var controller = this.application.controllers.get('le.le.userDetail');
var o=this.getController('le.le.userDetail');
if (!controller){
o.init(this.application);
}
o.createViewPort({title:'创建新用户',userId:0,userName:""});
[[[[在bfr.controller.le.le.userList的createViewPort方法中创建view
var w=Ext.create("bfr.view.le.le.userList",config);
或者直接:在按钮事件中,但这样对弹出窗体内事件,需要同时添加
var w=Ext.create("bfr.view.le.le.userDetail",{title:'创建新用户',userId:0,userName:""});
return w;
5.我想在按钮事件里面关闭当前窗体
btn.up("window").close();
6.我想做一个类似tabcontrol的页面
[[在items内,添加xtype为tabpanel的itme即可,它的items就是一个个的tab
{ xtype : 'tabpanel',
activeTab : 0,
region : 'center',
items : [ {
xtype : 'panel',
title : '新增权限',
items : [ {
//添加想要的控件
} ]
}, {
xtype : 'panel',
title : '复制权限',
items : [ {}
]
} ]
}
7.我想要个textbox 的输入框
[[[xtype为textfield,filedLabel指前面的label文字
{
xtype: 'textfield',
name: 'userAddr',
fieldLabel: '联系地址',
labelAlign: 'right',
labelWidth: 80,
anchor: '100%',
},
8.我想为textbox添加邮件验证:
[[[vtype验证
{
xtype: 'textfield',
name: 'userEmail',
fieldLabel: '电子信箱',
labelAlign: 'right',
labelWidth: 80,
anchor: '100%',
allowBlank:false,
vtype: 'email'
},
9:总结下textbox常用的属性
xtype:为textfield, name为取值时或form提交时字段名称
filedLabel:为前面text的文字,
labelAlign:文字停靠方向,可以在上面,或者左边时靠左靠右对齐
allowBlank:是否允许为空
vtype:格式验证
10.带下拉的combox.
{
xtype: 'combobox',
name: 'userSex',
fieldLabel: '用户性别',
labelAlign: 'right',
labelWidth: 80,
anchor: '100%',
store: sexStore,
editable:false,
selectOnFocus: true,
valueNotFoundText: 'no data',
displayField: 'valueName',
valueField: 'valueCode',
multiSelect: false,
triggerAction:'all',
mode:'local',
queryMode: 'local'
}
11.combox可以清除数据的.(这个是自定义的?)
{
xtype: 'ClearableComboBox',
name: 'deptId',
fieldLabel: '部门',
labelAlign: 'right',
labelWidth: 80,
anchor: '100%',
editable:false,
store:deptStore,
selectOnFocus: true,
displayField: 'deptCname',
valueField:"deptId",
multiSelect: false,
triggerAction:'all',
mode:'local',
queryMode: 'local'
},
12.日期控件
{
xtype: 'datefield',
name: 'expireDate',
fieldLabel: '账号过期时间',
labelAlign: 'right',
labelWidth: 80,
format: 'Y-m-d',
value: Ext.Date.add(new Date(), Ext.Date.DAY,30),
anchor: '100%',
}
13.我想要个splitcontrole的控件
{
xtype : 'panel',
title : 'panel内部',
collapsible : true,
items : [
{
xtype : 'panel',
title : '新增权限',
split: true,
region: 'north',//'east'
width:200,
items : [ ]
}, {
xtype : 'panel',
title : '复制权限',
region: 'center',
items : [ ]
} ]
}
14.spirtcontroler的一边能够收缩..只需要在上面的基础上,在split:true 后面添加 collapsed : false,
collapsible : true,
15.我想着panel标题栏上加按钮,类似在groupbox的caption加按钮,(C#通过放置按钮在上面实现)
在panel上添加tools即可.
tools: [
{
xtype: 'tool',
tooltip: '刷新',
action:'refresh',
type: 'refresh'
}
]
16.我也想添加菜单
17.我想要个,能输入值的combox…能够记录下来最近的输入.
18.我想点击按钮时,出发ajax请求.
var values=btn.up("window").down("form").getValues();
var callback=function(resObj){
//.....
}
Ext.Ajax.request({
url:'user.action',
params:values,
success:function(response){
var resObj=Ext.decode(response.responseText);
if (callBack){
callBack.call(this,resObj);
}
},
failure:function(response){
var resObj=Ext.decode(response.responseText);
Ext.MessageBox.alert('错误','请求失败');
return;
}
});
做了封装后的,
ePlat.Ajax.request(dispatcher.report.savefolder,values,callback);
19.将json字符串转成对象,var resObj=Ext.decode(response.responseText);