template String|Function
The template used to render the items. By default the widget displays only the text of the data item (configured via dataTextField
).
Example - specify template as a function
<input id="combobox" />
<script id="template" type="text/x-kendo-template">
<span>
<img src="/img/#: id #.png" alt="#: name #" />
#: name #
</span>
</script>
<script>
$("#combobox").kendoComboBox({
dataSource: [
{ id: 1, name: "Apples" },
{ id: 2, name: "Oranges" }
],
dataTextField: "name",
dataValueField: "id",
template: kendo.template($("#template").html())
});
</script>
Example - specify template as a string
<input id="combobox" />
<script>
$("#combobox").kendoComboBox({
dataSource: [
{ id: 1, name: "Apples" },
{ id: 2, name: "Oranges" }
],
dataTextField: "name",
dataValueField: "id",
template: '<span><img src="https://demos.telerik.com/kendo-ui/content/web/treeview/folder.png" alt="#: name #" style="vertical-align: middle;"/>#: name #</span>'
});
</script>