Gantt not refreshing with latest json data on item removal

I have the following code and adding an item to plan is refreshing the chart. But removing an item do not refresh the grid.
If I log the data variable I see the latest data without the removed item.
What can I use to force clear (I tried clearAll() and refreshData() before the gantt.init and that gives error) and refresh the chart correctly

$(function () {
       var data= { data: $cd.data };
        gantt.config.drag_links = false;
        gantt.config.readonly = true;
        gantt.config.columns = [
         { name: "text", label: " ", width: "*", tree: true }
        ];
        gantt.config.scale_unit = "month";
        gantt.config.date_scale = "%M %Y";
        gantt.init("gantt_chart");
        gantt.parse(data);

}();

Hi,
could you please provide a complete demo so we could reproduce the issue?
E.g. here:
docs.dhtmlx.com/gantt/snippet/

As I can see, if you delete a task from the ui (double click->Delete) - it is removed as expected.
The same if you delete task from code (gantt.deleteTask(id)). Maybe you’re doing something else?

We do not use editing capability of gantt.
Please see the behavior below .
We are doing editing for the object in another page and then redirect it to the page where we use gantt and initialize there. So in the other page if we add a new entry(object to the array the gantt is updated with that. But if we change a property of an existing object(which we are using as a criteria for removed object) and redirect to the page the page is not refeshing by removing that entry. If we force a browser refresh the data is updated.

Hello,
this may happen either because of browser cache, in this case try adding some dynamic value to gantt.load url:

gantt.load("dataurl.php?uid=" + Date.now());

Or it can happen if you redirect to gantt page before your changes were saved into the database. I.e. when gantt.load hits the backend, the backend script still saves changes so the client receives an old data.
Unfortunately I can’t suggest anything more specific without seeing what actually happens in your app

As I mentioned in the post I am using the gantt.parse with json data. When I log the json data using the console.log I see the latest json data and that do not have the deleted row. But the gantt is renderd just like old with the deleted row. If I do a refresh of the page using F5 then the deleted row is gone. So my question is there a property or method in gantt which I can use to force the refresh. I tried with refreshData() and render() after parse and that do not help.

Hello.

Is it correct that you’re initializing gantt on page for the first time and there is an extra rows? It seems like gantt should be empty until some tasks added. Have you tried to check if gantt contains any tasks before you call parse? If there is some tasks you could try to call clearAll right before calling parse. ( docs.dhtmlx.com/gantt/api__gantt_clearall.html ) If it still doesn’t work for you, could you show your sample where issue can be reproduced or link to problematic page?

If you call gantt.parse in order to replace the previously loaded dataset, please note that gantt.parse will append the provided dataset to the gantt without clearing the old state.
I.e.gantt.parse(dataset1); gantt.parse(dataset2); // gantt contains a union of dataset1 and dataset2
What you probably want to do is clearing gantt before calling parsegantt.clearAll(); gantt.parse(dataset);
Or even add a handler in order to do it automatically:

gantt.attachEvent("onBeforeParse", function(){ gantt.clearAll(); });

Doing the following helped

gantt.clearAll();
gantt.parse(data);

Thanks