急!!!!!!!!!新手关于EXTJS动态赋值的问题
时间:2011-08-11
来源:互联网
代码片段如下:
var StudentRecord = Ext.data.Record.create([
{name: 'id',type: 'string'}, // 客户类别ID
{name: 'bizname',type: 'string'}, // 客户类别ID
{name: 'bizvalue',type: 'string'}, // 客户类别ID
{name: 'attr0',type: 'string'}, // 客户类别ID
{name: 'attr1',type: 'string'}, // 客户类别名称
{name: 'valuetext',type: 'string'}, // 客户类别名称
]); ....省略
var mod_form = new Ext.FormPanel({
labelWidth: 80,
labelAlign: 'right',
frame: true,
defaults: {
width: 160
},
bodyStyle: 'padding:10px 5px 0',
defaultType: 'textfield',
monitorValid: true,
items: [
{
id: 'id',
name: 'id',
hidden: true
},{
id: 'bizname',
fieldLabel: '业务名称',
name: 'bizname',
disabled: true
},{
id: 'valuetext',
fieldLabel: '当前设定',
name: 'valuetext',
maxLength:20
},
{
xtype:'radiogroup',
id : 'valuetext',
name : 'valuetext',
width: 150,
fieldLabel:'业务设定',
items : [
{name:'aa' ,boxLabel:'1' ,xtype:'radio', inputValue: 0,checked: true },
{name:'aa' ,boxLabel:'2' ,xtype:'radio', inputValue: 1 }
]}
],...后面省略
问题1:请问如何通过代码为radiogroup中两个单选框选项中的boxLabel属性赋值,比如说现在boxlabel的值是1和2,我想通过代码让这个两个单选按钮的boxlabel显示3和4?
问题2: 根据record中的绑定好的项 bizvalue进行判断,如果bizvalue的值是0,则单选按钮的第一项被设置成默认选中,如果是1则单选按钮的第二个选项被选中,这个判断的JS脚本应该在怎样写呢
var StudentRecord = Ext.data.Record.create([
{name: 'id',type: 'string'}, // 客户类别ID
{name: 'bizname',type: 'string'}, // 客户类别ID
{name: 'bizvalue',type: 'string'}, // 客户类别ID
{name: 'attr0',type: 'string'}, // 客户类别ID
{name: 'attr1',type: 'string'}, // 客户类别名称
{name: 'valuetext',type: 'string'}, // 客户类别名称
]); ....省略
var mod_form = new Ext.FormPanel({
labelWidth: 80,
labelAlign: 'right',
frame: true,
defaults: {
width: 160
},
bodyStyle: 'padding:10px 5px 0',
defaultType: 'textfield',
monitorValid: true,
items: [
{
id: 'id',
name: 'id',
hidden: true
},{
id: 'bizname',
fieldLabel: '业务名称',
name: 'bizname',
disabled: true
},{
id: 'valuetext',
fieldLabel: '当前设定',
name: 'valuetext',
maxLength:20
},
{
xtype:'radiogroup',
id : 'valuetext',
name : 'valuetext',
width: 150,
fieldLabel:'业务设定',
items : [
{name:'aa' ,boxLabel:'1' ,xtype:'radio', inputValue: 0,checked: true },
{name:'aa' ,boxLabel:'2' ,xtype:'radio', inputValue: 1 }
]}
],...后面省略
问题1:请问如何通过代码为radiogroup中两个单选框选项中的boxLabel属性赋值,比如说现在boxlabel的值是1和2,我想通过代码让这个两个单选按钮的boxlabel显示3和4?
问题2: 根据record中的绑定好的项 bizvalue进行判断,如果bizvalue的值是0,则单选按钮的第一项被设置成默认选中,如果是1则单选按钮的第二个选项被选中,这个判断的JS脚本应该在怎样写呢
作者: xiao_yao80910 发布时间: 2011-08-11
JScript code
这个需求Ext没有相应的方法 通常我们借助Ext的DomQuery来操作元素
这个问题相对简单点 还不需要DomQuery
JScript code
{ xtype : 'radiogroup', id : 'valuetext', name : 'valuetext', width : 150, fieldLabel : '业务设定', items : [{ name : 'aa', id:'radiao1', boxLabel : '1', xtype : 'radio', inputValue : 0 }, { name : 'aa', id:'radiao2',//增加id boxLabel : '2', xtype : 'radio', inputValue : 1 }], listeners :{ 'render':function(){ //问题2解决方案 在渲染时做赋值操作 var bizVal = record.get('bizvalue'); if(bizVal == 0){ Ext.getCmp('radiao1').setValue(true); }else{ Ext.getCmp('radiao2').setValue(true); } } } }问题1解决方案:
这个需求Ext没有相应的方法 通常我们借助Ext的DomQuery来操作元素
这个问题相对简单点 还不需要DomQuery
JScript code
document.getElementById('radio1').nextSibling.innerHTML = 3; document.getElementById('radio2').nextSibling.innerHTML = 4;
作者: fanchuanzhidu 发布时间: 2011-08-11
晕死~~ 上边问题1解决方案中的id写错了 应该是'radiao1' 和'radiao2'
作者: fanchuanzhidu 发布时间: 2011-08-11
相关阅读 更多
热门阅读
-
office 2019专业增强版最新2021版激活秘钥/序列号/激活码推荐 附激活工具
阅读:74
-
如何安装mysql8.0
阅读:31
-
Word快速设置标题样式步骤详解
阅读:28
-
20+道必知必会的Vue面试题(附答案解析)
阅读:37
-
HTML如何制作表单
阅读:22
-
百词斩可以改天数吗?当然可以,4个步骤轻松修改天数!
阅读:31
-
ET文件格式和XLS格式文件之间如何转化?
阅读:24
-
react和vue的区别及优缺点是什么
阅读:121
-
支付宝人脸识别如何关闭?
阅读:21
-
腾讯微云怎么修改照片或视频备份路径?
阅读:28