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

MVVM bound DropDownList problem: first value appears blank

1 Answer 179 Views
DropDownList
This is a migrated thread and some comments may be shown as answers.
Siddhartha
Top achievements
Rank 1
Siddhartha asked on 23 Apr 2012, 09:37 PM
Problem reproduced at http://jsfiddle.net/MenYM/12/

I am using a drop down list, with following bindings to a view model:
1. source (simple array of items)
2. value 

I have also defined the data-role and, perhaps most importantly for this query, a data-option-label.

The problem is that if the data source defined in the view model is defined as an empty array, and at some point the data source is modified, the drop down list has an empty element, even before the data-option-label. (See the jsfiddle linked above).

On the other hand, if the data source had an element and afterwards was modified in the same way, the drop down list does not have an empty element.

What could be the problem here? Any pointers are appreciated.

Thanks,
Siddhartha Agrawal

1 Answer, 1 is accepted

Sort by
0
Georgi Krustev
Telerik team
answered on 24 Apr 2012, 05:30 PM
Hello Siddhartha,

 
The described behavior is expected. When you set the dataSource of the model, you just set the dataSource option of the DropDownList. In this case the DropDownList will not be initialized again. If you need to select an item then you will need to set the value of the model.

Regards,
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!
Tags
DropDownList
Asked by
Siddhartha
Top achievements
Rank 1
Answers by
Georgi Krustev
Telerik team
Share this question
or