From da0786ee80309fad104d8ffe87da4321dac5afa5 Mon Sep 17 00:00:00 2001 From: Alan Date: Fri, 23 Sep 2022 11:24:54 +0800 Subject: [PATCH] Roo/form/Radio.js --- Roo/form/Radio.js | 43 ++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 42 insertions(+), 1 deletion(-) diff --git a/Roo/form/Radio.js b/Roo/form/Radio.js index 4f83f53a7e..2a938f368c 100644 --- a/Roo/form/Radio.js +++ b/Roo/form/Radio.js @@ -60,7 +60,48 @@ Roo.extend(Roo.form.Radio, Roo.form.Checkbox, { this.el.dom.checked = 'checked' ; } - } + }, + /** + * Sets the checked state of the checkbox. + * On is always based on a string comparison between inputValue and the param. + * @param {Boolean/String} value - the value to set + * @param {Boolean/String} suppressEvent - whether to suppress the checkchange event. + */ + setValue : function(v,suppressEvent){ + + + //this.checked = (v === true || v === 'true' || v == '1' || String(v).toLowerCase() == 'on'); + //if(this.el && this.el.dom){ + // this.el.dom.checked = this.checked; + // this.el.dom.defaultChecked = this.checked; + //} + this.setChecked(String(v) === String(this.inputValue), suppressEvent); + this.el.dom.form[this.name] = v; + //this.fireEvent("check", this, this.checked); + }, + // private.. + setChecked : function(state,suppressEvent) + { + if (this.inSetChecked) { + this.checked = state; + return; + } + + if(this.wrap){ + this.wrap[state ? 'addClass' : 'removeClass']('x-menu-item-checked'); + } + this.checked = state; + if(suppressEvent !== true){ + this.fireEvent('check', this, state); + } + this.inSetChecked = true; + + this.el.dom.value = state ? this.inputValue : this.valueOff; + + this.inSetChecked = false; + + }, + }); \ No newline at end of file -- 2.39.2