Change selected value of kendo ui dropdownlist

后端 未结 5 988
忘掉有多难
忘掉有多难 2020-12-28 13:18

I have a kendo ui dropdownlist in my view:

$(\"#Instrument\").kendoDropDownList({
    dataTextField: \"symbol\",
    dataValueField: \"symbol\",
    dataSour         


        
5条回答
  •  天涯浪人
    2020-12-28 13:43

    You have to use Kendo UI DropDownList select method (documentation in here).

    Basically you should:

    // 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);
    

    If not, use:

    // selects item if its text is equal to "test" using predicate function
    dropdownlist.select(function(dataItem) {
        return dataItem.symbol === "test";
    });
    

    JSFiddle example here

提交回复
热议问题