EXTJS的CheckBox点击改变文字内容的封装

var cb_openValve = new Ext.form.Checkbox({
            id: "myCheckbox",
            name: "myCheckbox",
            fieldLabel: '复选框',
            boxLabel: '未选',
            checked: false,
            listeners: {
                click: {//点击事件
                    element: 'el',
                    fn: function (obj, o2, o3, o4, o5) {
                        var thisObj = Ext.getCmp(this.id);
                        var isCheck = thisObj.getValue();
                        if (isCheck) {
                            thisObj.setCheck();
                        }
                        else {
                            thisObj.setUnCheck();
                        }
                    }
                }
            },
            setText: function (value, textStr) {//基础设置方法
                var thisObj = Ext.getCmp(this.id);
                thisObj.setValue(value);
                thisObj.boxLabel = textStr;
                thisObj.getEl().down('.x-form-cb-label').update(textStr);
            },
            setCheck: function () {//勾选
                var thisObj = Ext.getCmp(this.id);
                thisObj.setText(true, '选择');
            },
            setUnCheck: function () {//不勾选
                var thisObj = Ext.getCmp(this.id);
                thisObj.setText(false, '未选');
            }
        });


你可能感兴趣的:(checkbox,ExtJs,点击事件)