Javascript 如何更改/设置剑道组合框中的值
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/11306268/
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
How to change/set value in kendo combobox
提问by Ashwin
Can anyone let me know how can we change the value of kendo combobox dynamically.
任何人都可以让我知道我们如何动态更改剑道组合框的值。
Fiddle is here - http://jsfiddle.net/ashwyn/yL6w3/1/
小提琴在这里 - http://jsfiddle.net/ashwyn/yL6w3/1/
In the above fiddle, when we click on click
then the shown value should be changed to three
(for eg.)
在上面的小提琴中,当我们单击时click
,显示的值应更改为three
(例如)
I found this link which list all datasource methods -
http://www.kendoui.com/documentation/framework/datasource/methods.aspx
我发现这个链接列出了所有数据源方法 -
http://www.kendoui.com/documentation/framework/datasource/methods.aspx
回答by user2493053
If you know the value you want, you can also do:
如果你知道你想要的值,你也可以这样做:
$("#MyComboBox").data("kendoComboBox").value(id);
回答by Tats_innit
working demohttp://jsfiddle.net/Bxsge/2/orhttp://jsfiddle.net/Bxsge/1/(behavior for demo when you will click on the link the select will change to three
selected value.)
工作演示http://jsfiddle.net/Bxsge/2/或http://jsfiddle.net/Bxsge/1/(演示的行为,当您单击链接时,选择将更改为three
选定值。)
selects by jQuery object // selects by index combobox.select(1); // selects item
通过 jQuery 对象选择 // selects by index combobox.select(1); // selects item
link: http://www.kendoui.com/documentation/ui-widgets/combobox/methods.aspx
链接:http: //www.kendoui.com/documentation/ui-widgets/combobox/methods.aspx
Hope this helps, :)
希望这可以帮助, :)
code
代码
$(function(){
var CB = $("select").kendoComboBox();
$("a").click(function(){
var $cbx = $("select").data("kendoComboBox")
$cbx.select(2);
});
});
?