0
我有一些包含radiogroups的ExtJS表单。Radiobutton没有被选中,同时以表格形式设置值
而且这些无线电组中的每一个都有2个无线电,其inputValue
s为true
和false
。
但是当我使用form.setValues(values)
设置表格值时,如果我想设置的radioButton值是false
,那么相应的收音机没有被选中。这适用于我的价值是true
。
这里是链接fiddle
如果你改变booleanRadio: true
这工作。
我的代码:
Ext.define('myView', {
extend: 'Ext.panel.Panel',
xtype: 'myView',
id: 'myViewContainer',
layout: 'vbox',
width: '100%',
initComponent: function() {
var me = this;
var allItems = [];
allItems.push(me.getMyForm());
Ext.applyIf(me, {
items: allItems
});
me.callParent(arguments);
},
getMyForm: function() {
var me = this;
var currentForm = {
xtype: 'form',
cls: 'y-form',
id: 'myForm',
trackResetOnLoad: true,
items: [
{
xtype: 'radiogroup',
fieldLabel: 'is Sponsored',
labelSeparator: '',
layout: 'hbox',
items: [
{
xtype: 'radiofield',
name: 'isSponsored',
boxLabel: 'Yes',
inputValue: true
},
{
xtype: 'radiofield',
name: 'isSponsored',
boxLabel: 'No',
inputValue: false
}
]
}
]
};
return currentForm;
}
});
Ext.define('myController', {
extend: 'Ext.app.Controller',
init: function() {
this.control({
'panel#myViewContainer': {
afterrender: this.retrieveFormValues
}
});
},
retrieveFormValues: function() {
var me = this;
var data = {isSponsored: false};
if (data != null && !Ext.Object.isEmpty(data)) {
var myFormContainer = Ext.getCmp('myViewContainer');
myFormContainer.getForm().setValues(data);
}
}
});
添加我的代码..我之前没有添加它,因为它很复杂。简化后我添加了。 – Harshal
我已经报告了一个与Sencha非常相似的问题,它被追踪为EXTJS-25448;除了可以将布尔值转换为字符串并将这些字符串值用作收音机的'inputValue'外,现在没有可用的解决方法。 – Alexander
我觉得这看起来像ExtJS Bug。 这不是一个解决方案。这只是解决方法。 var values = { booleanRadio:result? 1:0; }; –