ExtJS - Loop through CheckBoxGroup

I would like to get all checked items in the checkbox group, which is part of the form. Ultimately, they will be saved back to the database as a string, a comma-separated data format.

Thanks for any advice or help you can provide.

Here is how I defined my group:

new Ext.form.CheckboxGroup({
            id: 'newId',
            fieldLabel: 'Group A',
            name: 'broker',
            allowBlank: false,
            columns: 1,
            items: [{
                boxLabel: 'All',
                name: 'all',
                id: 'null'
            },
            {
                boxLabel: 'FS',
                name: 'fs',
                id: '1'
            },
            {
                boxLabel: 'Royal A',
                name: 'ra',
                id: '2'
            },
            {
                boxLabel: 'Point',
                name: 'sp',
                id: '6'
            }]
        })
+3
source share
2 answers

Use the method CheckBoxGroup getValue(). From the API docs :

GetValue ():

Gets an array of the selected Ext.form.Checkbox in the group.

Returns: an array of selected flags.

Then you can call join(",")in the returned array to get a comma separated list.

+5
source

getChecked .

DescCheck.getChecked();

getValue(), .

, ,

var selectedValue=  DescCheckGroup.getChecked();
for(var i=0;i<selectedValue.length;i++){
    console.log(select[i].inputValue);
}

. : fooobar.com/questions/1779003/... fooobar.com/questions/1779004/...

0

Source: https://habr.com/ru/post/1779001/


All Articles