Update local data and resources dynamically

Hi,
I would like to ask if you can provide some example how to update local data and resources dynamically. I have defined data and resources as arrays and fill (data and resources) with some data. 


Outside this component I will have button on which the data and resources should change from different local data, is it posible ? I tried some things but it did not work correctly.

Thank you



3 Replies 1 reply marked as answer

MS Monisha Sivanthilingam Syncfusion Team July 29, 2022 12:27 PM UTC

Hi Jakub,


Greetings from Syncfusion support.


Yes, we can dynamically reassign the data and resources passed to the Gantt. We have prepared a sample in which we can change the data and resources of the Gantt Chart dynamically through an external button click. The below code snippets demonstrate the solution.


App.component.html

 

<button ejs-button id='changedata' (click)='change()'>Change data and resources</button>

 


App.component.ts

 

change(): void {

  this.ganttObj.dataSource = [{

    TaskID: 1,

    TaskName: 'Project initiation',

    StartDate: new Date('03/29/2019'),

    EndDate: new Date('04/21/2019'),

    subtasks: [

      {

        TaskID: 2, TaskName: 'Identify site location', StartDate: new Date('03/29/2019'), Duration: 2,

        Progress: 30, work: 16, resources: [{ resourceId: 1, unit: 70 }, 6]

      },

      {

        TaskID: 3, TaskName: 'Perform soil test', StartDate: new Date('03/29/2019'), Duration: 4,

        resources: [2, 3, 5], work: 96

      },

      {

        TaskID: 4, TaskName: 'Soil test approval', StartDate: new Date('03/29/2019'), Duration: 1,

        work: 16, resources: [8, { resourceId: 9, unit: 50 }], Progress: 30

      },

    ]

  }];

  this.ganttObj.resources = [

    { resourceId: 1, resourceName: 'Martin Tamer' },

    { resourceId: 2, resourceName: 'Rose Fuller' },

    { resourceId: 3, resourceName: 'Margaret Buchanan' },

    { resourceId: 4, resourceName: 'Fuller King' },

    { resourceId: 5, resourceName: 'Davolio Fuller' },

    { resourceId: 6, resourceName: 'Van Jack' }

  ]

};

 


Sample: https://stackblitz.com/edit/angular-q3qvwz?file=app.component.ts


Regards,

Monisha.


Marked as answer

JA Jakub replied to Monisha Sivanthilingam August 1, 2022 06:28 AM UTC

Thank for your response, it's what I was looking for.

Regards,
Jakub



AS Aruna Shree Natarajan Syncfusion Team August 2, 2022 06:56 AM UTC

Hi Jakub,


We are glad that your issue is resolved. Please let us know if you need any other assistance. We will be happy to assist you.



Regards,

Aruna.


Loader.
Up arrow icon