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

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

3 Answers 53 Views
MVVM
This is a migrated thread and some comments may be shown as answers.
Shashwat
Top achievements
Rank 1
Shashwat asked on 13 Jun 2019, 01:11 PM

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

3 Answers, 1 is accepted

Sort by
0
Accepted
Angel Petrov
Telerik team
answered on 17 Jun 2019, 12:49 PM
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.
0
Shashwat
Top achievements
Rank 1
answered on 17 Jun 2019, 01:33 PM

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.

0
Angel Petrov
Telerik team
answered on 19 Jun 2019, 11:53 AM
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.
Tags
MVVM
Asked by
Shashwat
Top achievements
Rank 1
Answers by
Angel Petrov
Telerik team
Shashwat
Top achievements
Rank 1
Share this question
or