Sco*_*ter 2 forms checkbox extjs
我在窗口内有一个简单的ExtJS 4(xtype形式).它有两个字段和一个保存按钮.其中一个字段是字符串.这很好.如果它是空白的,则getValues()会将该字段留空.如果设置了,我就得到了价值.但是,复选框不同.如果选中它,我会得到'1'的值.不过,如果我取消勾选框(或不检查的话),我没有得到任何价值 - 域不在的GetValues的结果上市()!为什么??
items: [
{
xtype: 'checkbox',
name : 'insuranceVerified',
fieldLabel: 'insuranceVerified',
inputValue:'1',
value:'1' //does not make a difference
},
{
xtype: 'textfield',
name : 'ru',
fieldLabel: 'ru'
}
]
Run Code Online (Sandbox Code Playgroud)
我正在捕获保存按钮单击事件并在我的控制器中调用此函数:
updateEncounter: function(button) {
console.log('clicked the Save button');
var win = button.up('window'),
form = win.down('form'),
record = form.getRecord(),
values = form.getValues();
// values properly shows the ru field on the form, but only shows insuranceVerified if it's checked - is not in values if it's unchecked... ??!
debugger;
record.set(values);
this.getEncountersStore().sync();
win.close();
}
Run Code Online (Sandbox Code Playgroud)
我只是想出了别的东西,虽然这对我来说不是一个完整的答案:如果我改变上面的代码,那么就得到了表格(我假设从表格面板):
form = win.down('form').getForm(), // instead of win.down('form')
Run Code Online (Sandbox Code Playgroud)
然后,在该新对象而不是getValues()上使用getFieldValues(),即使未经检查,我现在也有复选框值.
values = form.getFieldValues(); // instead of getValues()
Run Code Online (Sandbox Code Playgroud)
但是,我得到的值是'false'(或true),而不是'0'或'1',就像我用inputValue指定的那样:'1'.
另外,我甚至尝试为字段'1'设置'值',无论我是否为getValues或getFieldValues()都这样做没有区别.
小智 6
这适合我.希望能有所帮助
{
xtype: 'checkbox',
boxLabel: modelFields[i].label,
name: modelFields[i].name,
//magic!
inputValue: 1,
uncheckedValue: 0
}
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
7662 次 |
最近记录: |