我有一个 kendo ui dropdownlist在我看来:
$("#Instrument").kendoDropDownList({
dataTextField: "symbol",
dataValueField: "symbol",
dataSource: data,
index: 0
});
如何使用 jQuery 更改它的选定值? 我试过:
$("#Instrument").val(symbol);
但它并没有像预期的那样工作。
最佳答案
您必须使用 Kendo UI DropDownList select
方法(here 中的文档)。
基本上你应该:
// get a reference to the dropdown list
var dropdownlist = $("#Instrument").data("kendoDropDownList");
如果您知道可以使用的索引:
// 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 示例 here
关于javascript - 更改 kendo ui 下拉列表的选定值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16106682/