gpt4 book ai didi

javascript - Kendo Ui Dropdown 结合 dataTextField

转载 作者:行者123 更新时间:2023-11-28 03:19:18 24 4
gpt4 key购买 nike

如何组合下拉列表中显示的多个值。示例姓氏+姓名

FULL DEMO

<script>
$("#dropdownlist").kendoDropDownList({
dataSource: [
{ Surname: "Sir1", Name: "Parent1", Id: 1 },
{ Surname: "Sir2", Name: "Parent2", Id: 2 }
],
optionLabel: "- Please Select -",
dataTextField: "Surname"+"Name",
dataValueField: "Id"
});
</script>

最佳答案

您可以为该列使用模板

$("#dropdownlist").kendoDropDownList({
dataSource: [
{ Surname: "Sir1", Name: "Parent1", Id: 1 },
{ Surname: "Sir2", Name: "Parent2", Id: 2 }
],
optionLabel: "- Please Select -",
dataTextField: "Surname"+"Name",
dataValueField: "Id",
template: kendo.template($("#template").html())
});

你的html

<input id="dropdownlist" />
<script id="template" type="text/x-kendo-template">
<span>
#: Surname # #: Name #
</span>
</script>

这是一些文档

https://docs.telerik.com/kendo-ui/api/javascript/ui/dropdownlist/configuration/template

关于javascript - Kendo Ui Dropdown 结合 dataTextField,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59315083/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com