Gant not rendering new tasks


#1

Hello,

I have problem in my project where when i add task to gantt, sometimes it is shown, rendered and sometimes it is not shown, after i call gantt.addTask it seems like chart is not re-renderd. I have tried adding render() and refreshData() functions after addTask in order to force it but nothing changes.
I have also tried to debug using getTaskByTime() before and after addTask call, and i can see that the task is added to gantt object just not rendere.
Is there any way to check if the state is corret, or that data i am pasing to the gantt is correct?

Code that is adding task after i get it from BE:
const startDate = new Date(data.startDate);
const endDate = new Date(data.endDate);
const wfItem = {
id: data.id,
text: data.name,
start_date: startDate,
end_date: endDate,
objectData: data,
};
this.gantt.addTask(wfItem, “0”);
this.gantt.render();
this.gantt.refreshData();

Thanks for any help that you can provide.
Nemanja


#2

Hello @coderns,

You can check if the task was added using the “onAfterTaskAdd” event, there are some similar evens for other actions, you find the full list of events by the following link:
https://docs.dhtmlx.com/gantt/api__refs__gantt_events.html

Here is a demo:
http://snippet.dhtmlx.com/5/59b656446

It’s not necessary to call the gantt.render() cause the task should be displayed without force render.

As a possible reason for your issue, could be the scenario, when you set the range of the scale with “gantt.config.start_date/end_date” and trying to add task outside of this range, in this case, the added task won’t be rendered, you can check it in the following demo:
http://snippet.dhtmlx.com/5/44309e0eb

You can read about this behavior by the following link:
https://docs.dhtmlx.com/gantt/api__gantt_start_date_config.html

If it’s not your issue, I can’t say for sure what is going wrong without more details or a demo. Could you please reproduce it in the demo above(reproduce=>click the “Share” button=> send me the new link), or you can send me an archive with all required files, which I will be able to run locally were and reproduce the issue.


#3

Hi @Siarhei,

i will look at the links that you have provided, and try to investigate.
I think our main problem is we delete task that gantt creates, and wait for RX patch from back end, to create new task. And on that place thinks some time fail some time work.

Thanks for your response, i’ll read this links and see if i can figure it out.
Nemanja