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

HTML <select> to DropDownList with templates?

2 Answers 161 Views
DropDownList
This is a migrated thread and some comments may be shown as answers.
Alexander
Top achievements
Rank 1
Alexander asked on 24 Aug 2015, 08:43 PM

Hi, is it possible to initialize a Kendo DropDownList from an HTML select element and use a template as well?

I want to do something like this:

<select id="locations">
   <option value="1" data-city="Albuquerque" data-state="NM">Albuquerque</option>
   <option value="2" data-city="Seattle" data-state="​WA">Seattle</option>
   <option value="3" data-city="Las Vegas" data-state="NV">Las Vegas</option>
</select>

<script type="text/x-kendo-template" id="city-state-template">
   #= data.city#, #= data.state#
</script>

<script>
$(document).ready(function() {
    $('#locations').kendoDropDownList({
        template: kendo.template($('#city-state-template').html())
    });​
});
</script>

 

2 Answers, 1 is accepted

Sort by
0
Konstantin Dikov
Telerik team
answered on 26 Aug 2015, 01:30 PM
Hello Alexander,

You could refer to the following forum thread, where the same requirement is discussed:
As you will notice, the only possible way for retrieving additional values is by using a data source and not the attributes of the select options.

Hope this helps.


Regards,
Konstantin Dikov
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
0
Alexander
Top achievements
Rank 1
answered on 26 Aug 2015, 01:55 PM
Thanks for the response. However it appears that there's no real difference at that point between initializing from a <select> element with <option>s vs an empty <div> element. In other words, no.
Tags
DropDownList
Asked by
Alexander
Top achievements
Rank 1
Answers by
Konstantin Dikov
Telerik team
Alexander
Top achievements
Rank 1
Share this question
or