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

Refresh Treeview with angular 5 and typescript

5 Answers 1575 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Abdoulah
Top achievements
Rank 1
Abdoulah asked on 24 Jan 2018, 08:43 AM
I using Kendo Treeview with Anguar 5

5 Answers, 1 is accepted

Sort by
0
Abdoulah
Top achievements
Rank 1
answered on 24 Jan 2018, 08:49 AM

Sorry for the fault above...

So I want to know how to make the Treeview component refresh it self because when  add new node to the tree I have to collapse and expand the parent node to see the new node. 

 

<kendo-treeview [nodes]="p.Items" textField="name" kendoTreeViewExpandable
[isChecked]="isItemChecked" kendoTreeViewSelectable
[expandBy]="'id'" [(expandedKeys)]="expanded_keys"
[hasChildren]="hasChildren" [children]="fetchChildren"
(selectionChange)="handleSelection($event)"
(checkedChange)="handleChecking($event)" #layers_tv id="layers_tv">
</kendo-treeview>
0
Georgi Krustev
Telerik team
answered on 25 Jan 2018, 08:50 AM
Hello Abdoulah,

In general, the TreeView component uses OnPush change detection strategy in order to reduce unnecessary checks. Thus it will miss when the passed data array is just mutated.

If the above solution is not feasible for you, could you provide a runnable demo that demonstrates the issue? Thus we will be able to review the case and find the best possible solution for you.

Regards,
Georgi Krustev
Progress Telerik
Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
0
Abdoulah
Top achievements
Rank 1
answered on 25 Jan 2018, 01:46 PM

Thanks Mr.Krustev for the reply .. the first solution is not feasible to me or may be I didn't test it properly (If you can explain it to me in more depth may be I can test it properly because I am a beginner in angular and typescript).

However, here is a link to demo of my problem:

https://embed.plnkr.co/6NRyVjWutVSB8oAzgDNV/

 

0
Georgi Krustev
Telerik team
answered on 26 Jan 2018, 08:23 AM
Hello Abdoulah,

The internal mutations of the data won't be catched by Angular when OnPush change detection strategy is used. The solution is to just pass a new instance of the data array.

public AddGroup(newItem) {
    this.data[0].items.push({text: newItem});
    this.data = this.data.slice();
}

This will spin an additional change detection cycle and the component will be updated. Check the modified demo:

https://plnkr.co/edit/gcjXdWv3aTjWEqC0Utue?p=info

Regards,
Georgi Krustev
Progress Telerik
Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
0
Abdoulah
Top achievements
Rank 1
answered on 28 Jan 2018, 06:51 PM
Thanks very much ... this fixed my problem.
Tags
General Discussions
Asked by
Abdoulah
Top achievements
Rank 1
Answers by
Abdoulah
Top achievements
Rank 1
Georgi Krustev
Telerik team
Share this question
or