Get error when open last parent task ( use API to get child )

I'm working on a feature to add children from the API when I expand the parent task. Initially, I will only get each parent task along with the isChild field to identify which task has children, then expand and call the API to add children. Currently, the code runs correctly, but with the last parent element, when expanding, I get an error: TypeError: Cannot read properties of undefined (reading 'visible') at TreeGrid.localExpand. Only the last element of the data list gets this error.

Below is my code file


Attachment: gantt_87565253.rar

1 Reply

SJ Sridharan Jayabalan Syncfusion Team January 6, 2025 01:37 PM UTC

Hi Thai,


Greetings from Syncfusion.


Thank you for sharing the details of your implementation and the code attachments.


Based on your description, we suspect that you are attempting to implement a "Load Child on Demand or Big Data Set" feature manually by utilizing the hasChildMapping property. However, hasChildMapping property is speacially made for default load child on demand feature. But without using loadChildOnDemand feature, you are used hasChildMapping may be the cause for your issue. Therefore, we suggest you use default load child on demand feature.


The loadChildOnDemand feature allows you to initially render only parent tasks and dynamically load child tasks on demand during expand or collapse actions. The hasChildMapping property plays a crucial role in this feature. By setting this property to true in the data source, the record is identified and rendered as a parent task. Child tasks are then retrieved via API calls during the expand or collapse actions.


To simplify and resolve the issue, we recommend utilizing the built-in loadChildOnDemand feature. You can find more details and implementation guidelines in the following links:


Demo - Gantt Chart · Big Data Set · Syncfusion React UI Components

Documentation - Data binding in React Gantt component | Syncfusion

 

If this feature does not align with your specific use case, or if the issue persists with your current implementation, please replicate the issue using the sample provided below for further analysis. We have prepared this sample based on your shared code snippets while commenting out some properties which is referred from external files:


Sample - https://stackblitz.com/edit/react-wojdlyxq-m56jd2a6?file=index.js

 

 

Regards,

Sridharan


Loader.
Up arrow icon