首页 > 解决方案 > 如何使用 ViewModel 值设置 KendoComboBox(jquery UI) 值?

问题描述

View(model) 从控制器 IActionResult 方法返回,但 Kendo 组合框选择的值不会像其他 UI 元素那样得到反映。

如何使用视图模型值设置组合框的选定值?

标签: asp.net-corekendo-uikendo-combobox

解决方案


您可以使用valueof设置它KendoComboBox。例如:

$("#test").kendoComboBox({
    dataTextField: "text",
    dataValueField: "value",
    dataSource: [
        { text: "", value: "1" },
        { text: "", value: "2" },
        { text: "", value: "3" },
    ],
    filter: "contains",
    suggest: true,
    index: -1,
    value: '@Model.yourValue'
});

推荐阅读