首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > JavaScript >

Extjs 的 checkbox全选跟反选

2012-09-16 
Extjs 的 checkbox全选和反选Ext.create(Ext.form.Panel, {title: Checkbox Group,width: 300,height:

Extjs 的 checkbox全选和反选

Ext.create('Ext.form.Panel', {    title: 'Checkbox Group',    width: 300,    height: 125,    bodyPadding: 10,    renderTo: Ext.getBody(),    items:[{        xtype: 'checkboxgroup',        fieldLabel: 'Two Columns',        id:'cg',        // Arrange radio buttons into two columns, distributed vertically        columns: 2,        vertical: true,        items: [            { boxLabel: 'Item 1', name: 'rb', inputValue: '1' },            { boxLabel: 'Item 2', name: 'rb', inputValue: '2', checked: true },            { boxLabel: 'Item 3', name: 'rb', inputValue: '3' },            { boxLabel: 'Item 4', name: 'rb', inputValue: '4' },            { boxLabel: 'Item 5', name: 'rb', inputValue: '5' },            { boxLabel: 'Item 6', name: 'rb', inputValue: '6' }        ]    }]    ,bbar: [        {            text: '反选',            handler: function() {        var array = Ext.getCmp('cg').items;        array.each(function(item){//        alert(item.getValue());        if(item.getValue()==true){        item.setValue(false);        }else{        item.setValue(true);        }        });//        alert(Ext.getCmp('cg').items.length);            }        },        '-',        {            text: '全选',            handler: function() {        var array = Ext.getCmp('cg').items;        array.each(function(item){            item.setValue(true);        });            }        }     ]});


只要对checkboxgrounp进行遍历就可以

热点排行