Weird outcome of gantt.load

Hey guys,

I am using gantt.load to load tasks from a database.

In my dev environment everything works fine, tasks get loaded correctly, but not in my prod environment.

The code is the same, the database call and data returned from that call is also the same, but on the gantt, although the tasks appear, I can’t edit any of them (double click to edit does nothing) and I don’t have a start date.

I’ve been debugging and so far I only notice a difference from one environment to another: my tasks json object in dev keeps numbers as integers:

{
duration: 1,
hours: 1,
id: 5148,
order: 1,
parent: 108
}

While on prod:

{
duration: “1”,
hours: “1”,
id: “5148”,
order: 1",
parent: “108”
}

And I have no idea why this is happening, but I guess it must have an impact.
Any thoughts?
Thanks in advance!

Hello,
Yes, it affects how everything works.
Duration can only accept integer parameters. If tasks do not have start_date, they try to take the date from its children.
You can try converting the necessary values to have the correct type. You need to have integer duration and string/Date start_date.
If you do not have start_date deliberately, you need to unschedule tasks.

In the following example you can see how to modify the values before parsing the data:
http://snippet.dhtmlx.com/46b2ca92a

https://docs.dhtmlx.com/gantt/api__gantt_onbeforeparse_event.html
https://docs.dhtmlx.com/gantt/api__gantt_ontaskloading_event.html

Hi Ramil,

As usual, you came and helped a lot!

Please check this: http://snippet.dhtmlx.com/4aea22192

I used the ontaskloading event and parsed all the needed fields from strings to numbers. The problem is that now all the other fields (name, date, etc) stay empty.

I thought I was only updating the task, but it seems that I’m creating a new version of the task? Can you please explain what happens in this event?

Many thanks!

---- EDIT:

I was not properly checking the indexOf method…
Here’s the updated snippet: http://snippet.dhtmlx.com/e90948a55

Everything is working now. You can close the issue.
Thanks again!