This is a migrated thread and some comments may be shown as answers.

DropdownList using template: displaying image based on property of the items

1 Answer 621 Views
DropDownList
This is a migrated thread and some comments may be shown as answers.
Sohel
Top achievements
Rank 1
Sohel asked on 26 Jul 2016, 08:32 PM
 Lets say i have a kendo dropdown like the following.
 
 var data = [
                        {text: "Item1", value:"1", type: "User"},
                        {text: "Item2", value:"2", type: "User"},
                        {text: "Item3", value:"3", type: "Group"}
                    ];

                    $("#dropdownlist").kendoDropDownList({
                        dataTextField: "text",
                        dataValueField: "value",
                        dataSource: data
                    });

Now, I would like to load glyphicon based on the type of the each item. In other words, glyphicon1 if item is of type  "user" and  glyphicon2 if item is of type "Group"

I know i can use the "template" to load icons with the items in the dropdown but how can i do it conditionally based on a property of the items?

1 Answer, 1 is accepted

Sort by
0
Dimiter Topalov
Telerik team
answered on 28 Jul 2016, 01:25 PM
Hi Sohel,

You can use the DropDownList template option, and conditionally add custom classes (or HTML elements with custom classes), based on the value of some model property, e.g.:

http://dojo.telerik.com/uwumO

Further detailed information about Kendo UI Templates, and multiple code snippets, illustrating it, are available in the following section of our documentation:

http://docs.telerik.com/kendo-ui/framework/templates/overview

I hope this helps.

Regards,
Dimiter Topalov
Telerik by Progress
Get started with Kendo UI in days. Online training courses help you quickly implement components into your apps.
Tags
DropDownList
Asked by
Sohel
Top achievements
Rank 1
Answers by
Dimiter Topalov
Telerik team
Share this question
or