Bug fix: "Widget does not select correct item if optionLabel is defined"

7 posts, 0 answers
  1. Curt Rabon
    Curt Rabon avatar
    45 posts
    Member since:
    Dec 2008

    Posted 12 Mar 2013 Link to this post

    In release 2012.3.1511, you state that the following fix was made for dropdown list:
    "Widget does not select correct item if optionLabel is defined"

    I think this is related to a problem I have.  You please give some clarification and simple scenario that this fixes?  Thanks.
  2. Georgi Krustev
    Admin
    Georgi Krustev avatar
    3707 posts

    Posted 14 Mar 2013 Link to this post

    Hello Curt,

     
    If the widget is created from SELECT element and the optionLabel is defined then the selected item will be one-item away from the expected one. The problem is addressed in the internal builds after the 2012 Q3 SP1 release. Check this jsBin demo, which shows the case (with older official version the selected item is not correct).

    Greetings,
    Georgi Krustev
    the Telerik team
    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. Curt Rabon
    Curt Rabon avatar
    45 posts
    Member since:
    Dec 2008

    Posted 15 Mar 2013 Link to this post

    Thanks, that helps.
  5. Nils
    Nils avatar
    2 posts
    Member since:
    Oct 2012

    Posted 03 Apr 2013 Link to this post

    Hello,

    I'm seeing what I think is the same issue with the latest release (2013.1.319). When constructing a dropdown based on an HTML select element with an "optionLabel" attribute, the dropdown automatically selects the first item instead of showing the optionLabel placeholder.

    Referencing you JS Bin entry: http://jsbin.com/agijut/1/edit

    Shouldn't the dropdown show the "Select item..." message? When I open the page, it comes up with "Item 1" selected.

    To me, it looks like the optionLabel is not working when used with a select HTML element.

    Is there a fix for this?

    Thanks,

    Nils

  6. Vladimir Iliev
    Admin
    Vladimir Iliev avatar
    2172 posts

    Posted 05 Apr 2013 Link to this post

    Hi Nils,


    Basically current behavior expected and it's intended - when normal "select" element is used it's first item from the list is selected by default. In current scenario if you need to initialize the DropDownList from select element and have the optionLabel selected you should include it in the list of items:

    <select id="select1">
        <option value=""> Select item...</option>
        <option>Item1</option>
        <option>Item2</option>
        <option>Item3</option>
        <option>Item4</option>
        <option>Item5</option>
    </select>
     
    <script>
        $("#select1").kendoDropDownList();
    </script>
     
    Kind regards,
    Vladimir Iliev
    the Telerik team
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
  7. Nils
    Nils avatar
    2 posts
    Member since:
    Oct 2012

    Posted 05 Apr 2013 Link to this post

    Thanks for the reply.

    But doesn't that make the behavior of "optionLabel" inconsistent? When using an "input" HTML element for the dropdown list, "optionLabel" is used and selected as the default item, while with a "select", it's handled differently. The previous behavior was more consistent in my opinion.
  8. Vladimir Iliev
    Admin
    Vladimir Iliev avatar
    2172 posts

    Posted 08 Apr 2013 Link to this post

    Hi Curt,

     
    Basically the previous behavior was inconsistent as when you initialize the widget from select list you are expecting to behave the same way as the original element. If you need the optionLabel to be selected by default I would suggest to initialize the widget from input element instead.

    Kind Regards,
    Vladimir Iliev
    the Telerik team
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Back to Top
Kendo UI is VS 2017 Ready