HTML <select> to DropDownList with templates?

3 posts, 0 answers
  1. Alexander
    Alexander avatar
    19 posts
    Member since:
    Jun 2012

    Posted 24 Aug 2015 Link to this post

    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. Konstantin Dikov
    Admin
    Konstantin Dikov avatar
    1793 posts

    Posted 26 Aug 2015 Link to this post

    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!
     
  3. Kendo UI is VS 2017 Ready
  4. Alexander
    Alexander avatar
    19 posts
    Member since:
    Jun 2012

    Posted 26 Aug 2015 Link to this post

    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.
Back to Top