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

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

6 Answers 42 Views
DropDownList
This is a migrated thread and some comments may be shown as answers.
Curt Rabon
Top achievements
Rank 1
Veteran
Curt Rabon asked on 12 Mar 2013, 05:20 PM
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.

6 Answers, 1 is accepted

Sort by
0
Georgi Krustev
Telerik team
answered on 14 Mar 2013, 02:23 PM
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!
0
Curt Rabon
Top achievements
Rank 1
Veteran
answered on 15 Mar 2013, 03:13 PM
Thanks, that helps.
0
Nils
Top achievements
Rank 1
answered on 03 Apr 2013, 08:37 AM
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

0
Vladimir Iliev
Telerik team
answered on 05 Apr 2013, 07:54 AM
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!
0
Nils
Top achievements
Rank 1
answered on 05 Apr 2013, 08:00 AM
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.
0
Vladimir Iliev
Telerik team
answered on 08 Apr 2013, 07:06 AM
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!
Tags
DropDownList
Asked by
Curt Rabon
Top achievements
Rank 1
Veteran
Answers by
Georgi Krustev
Telerik team
Curt Rabon
Top achievements
Rank 1
Veteran
Nils
Top achievements
Rank 1
Vladimir Iliev
Telerik team
Share this question
or