更改kendo ui下拉列表的选定值 [英] Change selected value of kendo ui dropdownlist
本文介绍了更改kendo ui下拉列表的选定值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我认为有一个 kendo ui dropdownlist:
$("#Instrument").kendoDropDownList({
dataTextField: "symbol",
dataValueField: "symbol",
dataSource: data,
index: 0
});
如何使用 jQuery 更改它的选定值?我试过了:
How can I change the selected value of it using jQuery? I tried:
$("#Instrument").val(symbol);
但它没有按预期工作.
推荐答案
你必须使用 Kendo UI DropDownList select
方法(文档在 此处).
You have to use Kendo UI DropDownList select
method (documentation in here).
基本上你应该:
// get a reference to the dropdown list
var dropdownlist = $("#Instrument").data("kendoDropDownList");
如果您知道可以使用的索引:
If you know the index you can use:
// selects by index
dropdownlist.select(1);
如果没有,请使用:
// selects item if its text is equal to "test" using predicate function
dropdownlist.select(function(dataItem) {
return dataItem.symbol === "test";
});
JSFiddle 示例 这里
JSFiddle example here
这篇关于更改kendo ui下拉列表的选定值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文