javascript 使用 ExtJS 检查单选按钮
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/9495763/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Check a radio button using ExtJS
提问by David
I may be missing something, but how do I programmatically check a radiobutton using ExtJS (v 3)?
我可能遗漏了一些东西,但是如何使用 ExtJS (v 3) 以编程方式检查单选按钮?
The following doesn't seem to always work
以下似乎并不总是有效
var radio = Ext.get("myradiobutton");
var radio = Ext.get("myradiobutton");
radio.set("checked,"");
radio.set("检查,"");
The radio is sometimes checked, sometimes not...
有时检查收音机,有时不检查...
radio.is(":checked") sometimes return true, sometimes false
radio.is(":checked") 有时返回真,有时返回假
Thanks
谢谢
回答by Andrey Selitsky
I'd suggested using this function: http://docs.sencha.com/ext-js/3-4/#!/api/Ext.form.Radio-method-setValue
我建议使用这个功能:http: //docs.sencha.com/ext-js/3-4/#!/api/Ext.form.Radio-method-setValue
var radio = Ext.get("myradiobutton");
radio.setValue(true);
回答by Evan Trimboli
Why not just use the DOM?
为什么不直接使用 DOM?
Ext.getDom('myradio').checked = true;