Error when refreshing "dataSource" and "resources"

In my application the Gantt will show only the resources selected by the user. And the user can change what resource will be show at will. I'm getting the error "Cannot read properties of undefined (reading 'ganttProperties')at ChartRows.getResourceParent (ej2-gantt.es2015.js:9484:1)" when calling the method "refresh" of gantt after choosing which resources to show.

The method that chooses which resources to show ("taskData" is the dataSource variable):

print1.png

The error occur after calling refresh:

print2.png


I attached snippets of code and a small demonstration video to better understanding of my scenario. Any help is appreciated


Attachment: files_5d53d5d2.zip


1 Reply 1 reply marked as answer

PS Premkumar Sudalaimuthu Syncfusion Team April 18, 2022 10:09 AM UTC

Hi Kayna ,


From the attached video, we understand that you want to update the resource dynamically. We were able to replicate this issue. This issue occurs because, both the data source and resources are dependent on each other for resource view, and you have changed them both at the same time. However, we can resolve this issue in the sample level itself by calling the setTimeout to execute the resource change after the data change is completed. The below code snippets demonstrate the solution.


Code snippets:


  btnClick() {

    var treegrid =

      document.getElementsByClassName('e-gantt')[0].ej2_instances[0];

    treegrid.resources = resourceCollection1;

    treegrid.refresh();

    setTimeout(

      function () {

        treegrid.dataSource = editingData;

      }.bind(this),

      100

    );

  }

 

 

 



Sample: https://stackblitz.com/edit/angular-frvhs4?file=data.ts



Regards ,

Premkumar S


Marked as answer
Loader.
Up arrow icon