[英](extjs) Get selected value of radio button in form. Not returning the value
我已經按照基本程序獲取我的單選按鈕表單的選定值。
....
xtype: 'radiofield',
name: 'timespan',
id: 'timespan',
value: 7,
checked: true,
fieldLabel: 'Time Span',
boxLabel: '7 days'
}, {
xtype: 'radiofield',
name: 'timespan',
value: '30',
fieldLabel: '',
labelSeparator: '',
hideEmptyLabel: false,
boxLabel: '30 days'
}, {
xtype: 'radiofield',
name: 'timespan',
value: '60',
fieldLabel: '',
labelSeparator: '',
hideEmptyLabel: false,
boxLabel: '60 days'
}, {
xtype: 'radiofield',
name: 'timespan',
value: 'all',
fieldLabel: '',
labelSeparator: '',
hideEmptyLabel: false,
boxLabel: 'All' ....
我用過的方法如下:
Ext.getCmp('filter_form').getForm().getValues()['timespan']
但是當我將它運行到控制台時,我沒有獲得所選按鈕的值,而是on
了這個詞。 是什么賦予了?! 我已經嘗試了幾種不同的getValues,getForm等組合,但我總是以on
或true
或false
。 這里發生了什么?
嘗試設置inputValue
屬性。 哪個是應該生成的輸入元素的value屬性的值,並且應該在作為表單的一部分提交時用作參數值。
{
xtype : 'radiofield',
name : 'timespan',
inputValue : '30',
hideEmptyLabel : false,
boxLabel : '30 days'
}
然后它可以作為
Ext.ComponentQuery.query('[name=timespan]')[0].getGroupValue();
弄清楚了! 原來我的extjs示例代碼有錯誤!
我將value
更改為inputValue
。 取自Sencha Docs, inputValue
是:
應該生成的輸入元素的value屬性中的值,並且應該在作為表單的一部分提交時用作參數值。 默認為:'on'
啊哈! 因為我沒有指定“真實”值,所以它默認為on
。
使用extjs示例/示例代碼時要小心!
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.