最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - ExtJS - Loop through CheckBoxGroup - Stack Overflow

programmeradmin3浏览0评论

I would like to get all of the checked items in a checkboxgroup that is part of a formpanel. Ultimately they would be saved back to database as a string, ma separated value format.

Thanks for any guidance or assistance you can provide.

Here is how I have my group defined:

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'
            }]
        })

I would like to get all of the checked items in a checkboxgroup that is part of a formpanel. Ultimately they would be saved back to database as a string, ma separated value format.

Thanks for any guidance or assistance you can provide.

Here is how I have my group defined:

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'
            }]
        })
Share Improve this question asked Dec 7, 2010 at 16:33 PixelMusePixelMuse 4708 silver badges24 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 5

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

getValue():

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

Returns: An array of the selected checkboxes.

You can then call join(",") on the returned Array to get a ma-separated list.

Did you tried getChecked for getting all checked boxes.

DescCheck.getChecked();

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

You can get that by looping through array like this

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

Please see the following answers: https://stackoverflow./a/27414218/2935802 https://stackoverflow./a/18309126/2935802

发布评论

评论列表(0)

  1. 暂无评论