Search code examples
reactjssyncfusiongantt-chart

How to force refresh the gantt


I would like refresh the gantt after some data get updated so at first i did it the react way by calling forceUpdate() and i expected taskbarTemplate will trigger as a consequence but that didn't happen. I've made this stackblitz showing the issue: the expected result is the change of items color to green when the Change color button is clicked (screenshot).


Solution

  • We can achieve your requirement by using refresh method of Gantt control. Please find the below code example.

    <button type="button" onClick={ev => {
            this.itemBgColor = 'green';
            var obj = document.getElementById('Default').ej2_instances[0];
            obj.refresh();
    }}>Change color</button>
    

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