Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
446 views
in Technique[技术] by (71.8m points)

checkbox - Get CheckboxGroup (or RadioGroup) values [EXTJS 3.4]

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?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...