Get CheckboxGroup (or RadioGroup) values [EXTJS 3.

2019-08-25 06:45发布

I have a checkboxgroup and a radiogroup. For both of them, I want to catch several values. For the checkboxGroup

var DescCheck = new Ext.form.CheckboxGroup({
    fieldLabel: 'Description of service : <span style="color: rgb(255, 0, 0); padding-left: 2px;">*</span>',
    width : 540,
    labelSeparator : '',
    items: [
        {boxLabel: 'Direct', name: 'Direct', inputValue: 'Direct'},
        {boxLabel: 'Fixed-day', name: 'day', inputValue: 'Fixed'},
        {boxLabel: 'Weekly', name: 'Weekly', inputValue: 'Weekly'}
    ]
});

I tried DescCheck.getValue() but it returned me

[object Object]

I tried DescCheck.getValue().inputValue and it returned me nothing.

For the radioGroup

var TypeCheck = new Ext.form.RadioGroup({

    items: [
        {boxLabel: 'New 1', name: '1', inputValue: '1'},
        {boxLabel: 'New 2', name: '2', inputValue: '2'},
        {boxLabel: 'New 3', name: '3', inputValue: '3'}
    ]

I tried TypeCheck.getValue().inputValue but it returned only the first selected item. How can I catch several checked boxes?

1条回答
Ridiculous、
2楼-- · 2019-08-25 07:07

Did you tried getChecked for getting all checked boxes.

DescCheck.getChecked();

Update

You should use getValue(), It returns the array of selected values.

You can get that by looping through array like this

var selectedValue = DescCheck.getValue();

for(var i=0;i<selectedValue.length;i++){
    console.log(select[i].inputValue);
}
查看更多
登录 后发表回答