- Home
- Forum
- Angular - EJ 2
- How prevent reinitialization od details
How prevent reinitialization od details
I am initializing data on all details at treegrid initial data load. When I expand or collapse it's initializing it again. How can I stop it?
Hi Mark,
We have checked the reported scenario. The behavior occurs because the data source is being assigned inside a lifecycle event (such as dataBound), which is triggered multiple times during TreeGrid actions like expand and collapse. As a result, the TreeGrid gets reinitialized whenever these actions occur.
To prevent this, we recommend initializing the data source only once, instead of assigning it inside events that fire repeatedly.
For example, you can assign the data in ngOnInit:
ngOnInit(): void { this.data = sampleData; } |
And remove data assignment from events like dataBound or similar life cycle events.
This ensures that the TreeGrid does not reinitialize during expand or collapse actions.
For reference:Uojbqbeq (duplicated) - StackBlitz
API reference: Index-default in Treegrid Control | Syncfusion
Please let us know if you still face any further issues.
Regards,
Sreedhar
First of all, data shown in the sample is different than in the json file. Secondly, I am using a template for the details, and I see that it goes through its initialization every time it collapses or expands.
Hi Mark,
Json data display treegrid:
In our sample, we have used sampleData, and the same data is being displayed in the TreeGrid. You can verify this in the sample provided below—the data assigned is rendered correctly in the TreeGrid:
Sample:
https://stackblitz.com/edit/angular-jxu7b3xz?file=src%2Fapp.component.html,src%2Fapp.component.ts,s…
Template Initialization issue:
We have checked the scenario with the detail template, and at our end the template content is created during the initial render and is only shown or hidden during expand and collapse actions.
Detail template Documentation: Detail template in Angular TreeGrid component | Syncfusion
Row template Documentation:Row template in Angular TreeGrid component | Syncfusion
Column template:Column template in Angular TreeGrid component | Syncfusion
To further analyze the behavior you are observing, could you please share more details about your template implementation? Specifically:
- How the template is defined (detail template / row template)
- Where the initialization logic is placed (e.g., lifecycle hooks or events)
- A minimal reproducible sample along with video replication steps
This will help us confirm whether the issue can be reproduced at our end and provide a more precise solution.
Regards,
Sreedhar
- 3 Replies
- 2 Participants
-
MG Mark Goldin
- May 12, 2026 07:02 PM UTC
- May 15, 2026 04:36 AM UTC