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; }; –