Search code examples
reactjssyncfusiongantt-chartej2-syncfusion

How to update a task dynamically in the syncfusion's gantt (only one task)


In the gantt's documentation, i didn't find a method to update a single task data. All we have for updating is the updateDataSource() method and the worst is that we need call refresh() after it to see the update in the dom which refresh all the tasks and not the only modified task. In this stackblitz demo i've tried only pass the task i need to update to updateDataSource() but the result is that only that same task will be displayed In the gantt's editing demo when a task is updated via the dialog, only that task will refresh and not all task , there should be a method that is not exposed in the api that does it

i'm using gantt's react lib.


Solution

  • We can update a particular task using updateRecordById method. For this we need to inject Edit module. Please refer the below documentation link. Documentation - https://ej2.syncfusion.com/react/documentation/gantt/managing-tasks/#update-task-values-using-method

    var ganttObj = document.getElementById('Default').ej2_instances[0];
    var data = { TaskID: 2, Duration: 7 };
    ganttObj.updateRecordByID(data);
    

    Sample - https://stackblitz.com/edit/react-6lscfc-hynwz7?file=index.js