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

data-value not working when zero

3 Answers 294 Views
DropDownList
This is a migrated thread and some comments may be shown as answers.
Tom B
Top achievements
Rank 1
Tom B asked on 12 Mar 2015, 04:54 PM
The drop down list is not setting it's value when the value is zero (data-value="0") and I'm not sure why.  The seems to treat the values as numeric instead of a string.  Please see the example:

http://dojo.telerik.com/UroFA

3 Answers, 1 is accepted

Sort by
0
Georgi Krustev
Telerik team
answered on 16 Mar 2015, 04:16 PM
Hello Randy S,

Indeed, the parseOption functionality recognizes the "0" as a number and then sets it to the widget. The MultiSelect widget on the other hand cannot select 0 (as a number) as it expects string as a value option.

I would suggest you use the value binding in order to set the value you want.

Let me know if I can be of a further assistance.

Regards,
Georgi Krustev
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
0
CDC
Top achievements
Rank 1
answered on 16 Mar 2015, 05:10 PM
We are binding data on the server (rendering declarative html) so using mvvm isn't really an option for us in this case.   

The DropDownList will bind with data-value and value IF you use an INPUT tag.  We were using a SELECT tag to back the control.  Why wouldn't it work the same for a SELECT and an INPUT.  In the case of a DropDownList a SELECT element seems more appropriate anyway.  Another Dojo showing this:

http://dojo.telerik.com/UroFA/3

I guess we will need to change our dropdown rendering to use an INPUT.
0
Georgi Krustev
Telerik team
answered on 18 Mar 2015, 04:17 PM
Hello CDC,

The value attribute works for INPUT element, because it has value attribute (INPUT help). The SELECT element, however, does not have value attribute, hence it is just ignored by HTML.

In this case, the best solution will be to use INPUT elements as it has value attribute.

Regards,
Georgi Krustev
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
Tags
DropDownList
Asked by
Tom B
Top achievements
Rank 1
Answers by
Georgi Krustev
Telerik team
CDC
Top achievements
Rank 1
Share this question
or