Hi,
I’m trying out Gantt for a project using server-side data and found myself having strange problems adding projects (but not tasks or milestones). Hunting for the problem led me to what I’m about to show below. While not entirely certain, I believe there might be a bug in gantt. To be sure to exclude my own potential buggy code I’ll show this using one of your own demos and using only the javascript console.
To see this, please follow along using these steps:
Go to this gantt demo page: (it’s relevant as it also uses server-side data)
http://docs.dhtmlx.com/gantt/samples/01_initialization/04_connector_json.html
(If it’s cluttered, feel free to remove all current tasks, they are not needed to show the problem)
Open the javascript console and add a task of type “task”:
gantt.addTask({ text: "Test", start_date: "2014-07-19", duration: 2, progress: 0, type: "task" });
Lookup id of just added task
gantt.eachTask(function(task){console.log(task.id + " " + task.text);})
Outputs (for instance)
132 Test
Take a look at the task (for verification purposes only)
gantt.getTask(132);
Looking at the object, it contains this
$index 1
$level 1
$no_end false
$no_start false
$open false
$rendered_parent 1
$rendered_type "task"
$source []
$target []
duration 2
end_date Mon Jul 21 2014 00:00:00 GMT+0200 (CEST) {}
id "132"
parent 1
progress 0
start_date Sat Jul 19 2014 00:00:00 GMT+0200 (CEST) {}
text "Test"
type "task"
Up to this point everything works as expected.
Now change the type to “project”
gantt.getTask(132).type = "project";
gantt.updateTask(132);
Take another look at the task (now being a “project”)
gantt.getTask(132);
Produces
$index 1
$level 1
$no_end true
$no_start true
$open false
$rendered_parent 1
$rendered_type "project"
$source []
$target []
duration ""
end_date ""
id "132"
parent 1
progress 0
start_date ""
text "Test"
type "project"
Meaning that the values in these fields were emptied…
duration 2
end_date Mon Jul 21 2014 00:00:00 GMT+0200 (CEST) {}
start_date Sat Jul 19 2014 00:00:00 GMT+0200 (CEST) {}
…and these values in these fields were changed (probably as result of emptied fields above)
$no_end true
$no_start true
At this point everything still looks fine in the gantt, but as soon as I trigger a redraw (using gantt.render() for instance), the Test task gets a single pixel width to the far left of the visual bar-area. I also get three “invalid day index” errors.
All help and comments appreciated,
Fred S
PS. It’s probably worth noting that this problem does not exist if one instead tries it out on this demo: http://docs.dhtmlx.com/gantt/samples/01_initialization/01_basic_init.html. Probably because it’s not server-side data?