在Kendo Multiselect中加载预先选择的值

时间:2018-03-26 12:53:39

标签: javascript c# jquery asp.net kendo-ui

我在项目中使用了Kendo MultiSelect。

<script>
    $(document).ready(function () {
        $("#multiselect").kendoMultiSelect({
            placeholder: "--Select Public Houses--",
            dataTextField: "PublicHouseName",
            dataValueField: "PublicHouseId",
            autoBind: true,
            dataSource: {
                transport: {
                    read: {
                        dataType: "json",
                        url: "/book/getallpublichouses"
                    }
                }
            }
        });
    });
</script>

如何在多选中传递选定的值并将其设置为预选?

1 个答案:

答案 0 :(得分:0)

您可以根据dataValueField

选择值
<script>
    $(document).ready(function () {
        $("#multiselect").kendoMultiSelect({
            placeholder: "--Select Public Houses--",
            dataTextField: "PublicHouseName",
            dataValueField: "PublicHouseId",
            autoBind: true,
            dataSource: {
                transport: {
                    read: {
                        dataType: "json",
                        url: "/book/getallpublichouses"
                    }
                }
            }
        });
        //selects your object with the PublicHouseIds of 25 and 30
        //pass in as strings
        $("#multiselect").getKendoMultiSelect().value(["25", "30"]);
    });
</script>

以下是一个演示:http://dojo.telerik.com/IMUXaJaM/2