Kendo UI Dropdownlist with a given set of templates does not work

I am trying to use a Kendo dropdown that uses a template. I have a page where the user can select a dataset and this dataset with popup dropdowns using values. Most of my dropdown menus do not use templates, however one that does not work properly uses templates.

My template:

<script type="text/x-kendo-tmpl" id="dropdownTemplate"> <div> <p><strong>#= Name #</strong></p> <p>#= Description #</p> </div> </script> 

My dropdown definition:

 $("#listTemplates").kendoDropDownList({ dataTextField: "Name", dataValueField: "ChartTemplateId", template: kendo.template($("#dropdownTemplate").html()), change: listTemplatesChange }); 

How do I populate my dropdown menu:

  portalTemplatesModel = [ [{ Name: "Test", Description: "Long Description", ChartTemplateId: "1" }], [{ Name: "Test2", Description: "Long Description2", ChartTemplateId: "2" }] ] for (i = 0; i < portalTemplatesModel.length; i++) { $("#listTemplates").data("kendoDropDownList").dataSource.add(portalTemplatesModel[i]); } 

My setter:

 var ddTemplates = $("#listTemplates").data("kendoDropDownList"); ddTemplates.select(function (dataItem) { return dataItem.value === placeHolderChart.ChartTemplateId; }); 

dataItem is as follows:

  [{ Name: "Test", Description: "Long Description", ChartTemplateId: "1" }] 

I noticed that in the documentation for the installation, you should use either a value or an element. However, with the dataset that I use, it seems that another object is used that does not contain a value or text, like other drop-down lists that do not use templates.

Thank you in advance!

+4
source share
2 answers

I had a similar problem. It seemed that it was necessary to add data. before your data value calls. i.e. # = data.Description #

+2
source

you can fill it out by specifying $ {Name} and $ {Description} in your kendoTemplate file, when the data source is read, the template will receive values, and you will see it according to your template.

0
source

All Articles