日期:2014-05-16  浏览次数:20444 次

extjs 修改checkboxgroup源代码--设置单个选项置灰
Ext.override(Ext.form.CheckboxGroup,{
setItemDisable:function(id,disabled )
{
this.items.each(function(item) {
if(item.getName() == id)
{
item.setDisabled(disabled);
}
        });
}
});

Ext.override(Ext.form.Checkbox,{
onRender : function(ct, position){
        Ext.form.Checkbox.superclass.onRender.call(this, ct, position);
        if(this.inputValue !== undefined){
            this.el.dom.value = this.inputValue;
        }
        this.wrap = this.el.wrap({cls: 'x-form-check-wrap'});
        if(this.boxLabel){
           this.labelelment =  this.wrap.createChild({tag: 'label', htmlFor: this.el.id, cls: 'x-form-cb-label', html: this.boxLabel});
        }
        if(this.checked){
            this.setValue(true);
        }else{
            this.checked = this.el.dom.checked;
        }
        // Need to repaint for IE, otherwise positioning is broken
        if(Ext.isIE){
            this.wrap.repaint();
        }
        this.resizeEl = this.positionEl = this.wrap;
    }
});
Ext.override(Ext.form.CheckboxGroup,{
setItemDisable:function(id,disabled )
{
this.items.each(function(item) {
if(item.getName() == id)
{
item.setDisabled(disabled);
}
        });
},
setItemValue:function(index,blabel,value)
{
var i = -1;
this.items.each(function(item){
i++;
if(i == index)
{
item.boxLabel = blabel;
Ext.get(item.labelelment.id).dom.innerHTML = blabel;
item.setValue(value);
}
});
this.doLayout();
},
setCheckDisable:function(index,disabled)
{
var i = -1;
this.items.each(function(item){
i++;
if(i == index)
{
item.setDisabled(disabled);
}
});
}

});