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

MVVM DropDownList data-value-field is required even if data-value-primitive is set to false

1 Answer 309 Views
DropDownList
This is a migrated thread and some comments may be shown as answers.
Oleksandr
Top achievements
Rank 1
Oleksandr asked on 28 Jul 2015, 01:19 PM

I created a demo based on standard dropdown MVVM demo which shows the behavior. For some reason DropDownList ​doesn't set it's value binding destination in case data-value-field attribute is not present. If you uncomment my attribute

comment-data-value-field="ProductID"

​example works fine.

But it took me a while to figure out what's missing there. I can't understand why I must specify data-value-field even though I set data-value-primitive="false", so data-value-field isn't used in any case. Documentation also says that dataValueField could be absent.

 

1 Answer, 1 is accepted

Sort by
0
Plamen
Telerik team
answered on 30 Jul 2015, 05:31 AM
Hello,

By default the DropDownList uses the selected item from the data to update the View-Model field when the initial value is null. If you set data-value-primitive attribute to true it only changes the behavior so the View-Model field should be updated with the item value field. All the other configurations have to be the same so that the value is coming correctly from the datasource. Here is the documentation article about this behavior.

Hope this information will be helpful.

Regards,
Plamen
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
Oleksandr
Top achievements
Rank 1
Answers by
Plamen
Telerik team
Share this question
or