ExtJS2.X内CheckboxGroup取值和赋值的操作(重写getValue和setValue)

Ext.override(Ext.form.CheckboxGroup, {

    getValue: function(){

        var v = [];

        this.items.each(function(item){

            if (item.getValue()) {

                v.push(item.value);

            }

            else {

                //v.push('');

            }

        });

        return v.toString();

    },

    setValue: function(vals){

        var a = [];

        if (Ext.isArray(vals)) {

            a = vals;

        }

        else {

            a = vals.split(',');

        }

        this.items.each(function(item){

            item.setValue(false);

            for (var i = 0; i < a.length; i++) {

                var val = a[i];

                if (val == item.value) {

                    item.setValue(true);

                }

            };

                    });

    }

});

posted on 2011-11-01 16:39  毛毛亟亟  阅读(732)  评论(0)    收藏  举报

导航