Extjs 重写CheckboxGroup的getValue和setValue方法

//20140711 marm 重写CheckboxGroup的getValue和setValue方法(如果多处用到的话可以移到公用js里面) 

/*************************/
        Ext.override(Ext.form.CheckboxGroup, {
            getValue: function () {
                var v = new Array();//返回的是数组
                this.items.each(function (item) {
                    if (item.getValue()) {
                        v.push(item.inputValue);
                    }
                });
                return v;//v.join(',');可以变为字符串返回
            },
            setValue: function (v) {
                this.items.each(function (item) {
                    // alert(v.indexOf(item.inputValue));
                    if (v != undefined)
                        item.setValue(v.indexOf(item.inputValue) != -1);
                });
            }
        });
        /****************************/

posted @ 2014-07-11 10:23  初升的太阳  阅读(414)  评论(0编辑  收藏  举报