我在项目中使用了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>
如何在多选中传递选定的值并将其设置为预选?
答案 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>