Extjs中checkboxgroup以及radiogroup的使用

标签:
extjs后台获取checkboxgroupinputvalueit |
分类: ExtJS |
在extjs中,为便于功能实现,通常会使用到checkboxgroup以及radiogroup的控件,在实际使用中,如何获取或设置该控件的值,通过搜索及自身摸索实践,主要可采取如下方式:
}
//监听事件
}
}
}, {
boxLabel :
'否',
name :
'check',
inputValue :
false,
checked :
true,
listeners :
{
'check' : function(){
//监听事件
}
}
}],
fieldLabel : '是否修改名称'
}
1:Checkboxgroup
代码:
{
xtype:'checkboxgroup',
name:'FileItype',
fieldLabel:'文件类别',
items:[
{boxLabel:'专用通知',inputValue:1,checked:true},
{boxLabel:'专题报告',inputValue:2},
{boxLabel:'会议纪要',inputValue:3}]},
如图:
var
FileItype=showserach.getForm().findField('FileItype').getValue();
var s='';
for(i=0;i<FileItype.length;i++)
{s=s+','+FileItype[i].inputValue}
ds.baseParams={FileItype:s.substr(1)};
传递至后台,以字符串的方式进行,例如:http://s14/middle/6543cca5h8e2b34bf46cd&690
2:Radiogroup的使用
该功能,在本人项目中,在修改模块中使用,通过getForm().load(),从后台以JSON格式获取数据
JSON数据格式:
[{'FileItype':'3','Filedate':'2010-8-13','FileNum':'2010质管-JY-064','KeyWord':'滤光膜','FileRname':'关于滤光
膜处理的会议纪要','FileUnit':'IQA','Filedetail':''}]
前台代码:
{
xtype:'radiogroup',
fieldLabel:'文件类别',
name:'FileItype',
//后台返回的JSON格式,直接赋值;
items:[
{boxLabel:'专用通知',name:'FileItype',inputValue:1},
{boxLabel:'专题报告',name:'FileItype',inputValue:2},
{boxLabel:'会议纪要',name:'FileItype',inputValue:3}
]},
这里之所以,重复设置了name:'FileItype',主要是如果在radiogroup的items中,不设置相同的name,在使用上,将出现radio可以多选的现象
http://s13/middle/6543cca5hd8db1334721c&690
这样很容易误导使用者,但是如果items设置的name不与radiogroup的name相同,通过getForm().findField('FileItype').getValue()获取的null。
这样很容易误导使用者,但是如果items设置的name不与radiogroup的name相同,通过getForm().findField('FileItype').getValue()获取的null。
为此,通过设置radiogroup的name与radiogroup中items控件相同name,可以获取radiogrou的值
代码:
var
FileItype=EditfileForm.getForm().findField('FileItype').getValue().inputValue;
url:"SaveFilesList.asp?action=Edit",
params:
{fileid:parafileid,
FileItype:FileItype},
但是向后台传递的数值有2个,笔者目前是通过在后台,删除其中一个的方法才实现的
FileItype=Left(Trim(request("FileItype")),1)
参考:
关键字: ext2.2 radiogroup监听事件
{
xtype : 'radiogroup',
allowBlank : false,
width : 100,
labelSeparator :
Color.blank,
items : [{
boxLabel :
'是',
name :
'check',
inputValue :
true,
listeners : {
'check' : function(checkbox, checked){
if(checked){//只有在点击时触发
}
}
}
实战总结:(关键代码)
************************CheckboxGroup控件*******************************
NationPerson =
Ext.extend(Ext.form.CheckboxGroup,{