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

Value not set with MVVM

5 Answers 126 Views
DropDownList
This is a migrated thread and some comments may be shown as answers.
Matjaz
Top achievements
Rank 1
Matjaz asked on 25 Jul 2015, 06:55 AM

When I choose item, value (MVVM) is null. After choosing another item, value is set to previously selected item and so on.

dojo‚Äč

5 Answers, 1 is accepted

Sort by
0
Plamen
Telerik team
answered on 29 Jul 2015, 05:34 AM
Hello,

The reason for this behavior is the usage of the cascade event instead of the change event that is used here in the demo where the value is coming correctly. You can read more about the difference in the two events in our documentation here

Regards,
Plamen
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
0
Matjaz
Top achievements
Rank 1
answered on 31 Jul 2015, 07:51 AM
Yes, I read the documentation, but I need cascade, because I must track changes made in code.
0
Plamen
Telerik team
answered on 04 Aug 2015, 05:32 AM
Hi Matjaz,

In such case you should trigger the change in the viewmodel as for example it is achieved in your page by adding the following line:
viewModel.selectedProduct = 6;

Here is the updated dojo page. Hope this will help you solve the issue.

Regards,
Plamen
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
0
Saop
Top achievements
Rank 1
answered on 17 Aug 2015, 10:27 AM

I do not know, how this should help me.

I wrap entire cascade event handler in window.setTimeout and it works.

Apparently cascade event is fired before blur is called (MVVM value is updated on blur) in _click method of DropDownList.

Just tell me if this is by design? I would expect value would be updated before cascade is called, so I can use it in cascade event handler.

0
Plamen
Telerik team
answered on 18 Aug 2015, 08:05 AM
Hi,

If you want to set the value programmatically on a button click you can use following code :
viewModel.set("selectedProduct", 6);

Here is my dojo page. If it still does not work correctly at your side please share send the exact code use so we could inspect it.

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