Value not set with MVVM

6 posts, 0 answers
  1. Matjaz
    Matjaz avatar
    94 posts
    Member since:
    Jun 2014

    Posted 25 Jul 2015 Link to this post

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

    dojo

  2. Plamen
    Admin
    Plamen avatar
    2729 posts

    Posted 29 Jul 2015 Link to this post

    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!
     
  3. Kendo UI is VS 2017 Ready
  4. Matjaz
    Matjaz avatar
    94 posts
    Member since:
    Jun 2014

    Posted 31 Jul 2015 Link to this post

    Yes, I read the documentation, but I need cascade, because I must track changes made in code.
  5. Plamen
    Admin
    Plamen avatar
    2729 posts

    Posted 04 Aug 2015 Link to this post

    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!
     
  6. Matjaž
    Matjaž avatar
    80 posts
    Member since:
    Jul 2015

    Posted 17 Aug 2015 Link to this post

    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.

  7. Plamen
    Admin
    Plamen avatar
    2729 posts

    Posted 18 Aug 2015 Link to this post

    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!
     
Back to Top
Kendo UI is VS 2017 Ready