View not refreshing for MVVM model with another custom model array as child

4 posts, 1 answers
  1. Shashwat
    Shashwat avatar
    2 posts
    Member since:
    Jun 2019

    Posted 13 Jun Link to this post

    I tried finding something similar in this forum but maybe I'm not using the right terms, so here it is:

    I have a custom model (created using kendo.define), lets call it "Master". It has a property "Children" which is an ObservableArray of another custom model. A property (say, "Type") defined in Master is rendered in children template. If this property changes, the child template doesn't re-render.

    1. Question 1: Considering such a setup where a master property is rendered in a child template, how can child re-render when master property changes?
    2. Question 2: Is there a better way to convert server-provided data into custom Model objects than what is being done in the example?

    I have read that data sources should not be nested so deeply, is that the problem? What would be a more appropriate approach for MVVM with a nested model?

    Example Dojo: https://dojo.telerik.com/isiNeJaF

  2. Answer
    Angel Petrov
    Admin
    Angel Petrov avatar
    1103 posts

    Posted 17 Jun Link to this post

    Hi,

    Straight to the questions on hand.

    1. The children can be re-rendered if change is registered for the observable collection. Here is a possible solution.
    2. The code logic seems correct. Generally speaking the solution depends on the requirements.

    As for working with nested object generally the problem is that on should trigger change for all levels in order to update the UI correctly. Our internal logic does not handle hierarchical dependencies by default.

    Regards,
    Angel Petrov
    Progress Telerik
    Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
  3. Shashwat
    Shashwat avatar
    2 posts
    Member since:
    Jun 2019

    Posted 17 Jun Link to this post

    Hello,

    Thank you, I get the trigger('change') logic now.

    Just to ensure I'm following the suggested practice for future screens, how should we create view models to handle hierarchical data, like the one I suggested?

    Would https://docs.telerik.com/kendo-ui/api/javascript/kendo/methods/observablehierarchy be of any use?

    Thanks in advance.

  4. Angel Petrov
    Admin
    Angel Petrov avatar
    1103 posts

    Posted 19 Jun Link to this post

    Hi,

    The pointed article will work if a self-referencing hierarchy is used and the items inside the data structure are presented in a flat structure which is not the case. 

    Regards,
    Angel Petrov
    Progress Telerik
    Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Back to Top