Hi,
I’m seeing an unexpected behaviour regarding the returned ID when I’m using server-side data and add tasks. I believe it might be due to a bug.
If I am to add a task, I use the gantt.addTask method as described here:
http://docs.dhtmlx.com/gantt/api__gantt_addtask.html
The actual call:
var taskId = gantt.addTask({
id:10,
text:"Task #5",
start_date:"02-09-2013",
duration:28
}, "project_2");
Example 1 - using local data everything works as expected
Now, if I go to your demo page with a very basic gantt…
http://docs.dhtmlx.com/gantt/samples/01_initialization/01_basic_init.html
…and open the javascript console, I can add a task and get its’ ID back:
gantt.addTask({ text: "Test", start_date: "2014-04-04", duration: 2, progress: 0, type: "task" });
returns 1405940833173
Now I can use that ID to get the task I just added:
gantt.getTask(1405940833173);
returns the object
Example 2 - using server-side data the returned ID is wrong
However, if I do this on your demo that’s using server-side data…
http://docs.dhtmlx.com/gantt/samples/01_initialization/04_connector_json.html
…and perform the exact same operation I get this instead:
gantt.addTask({ text: "Test", start_date: "2014-04-04", duration: 2, progress: 0, type: "task" });
returns 1405940929703
Now I once again try to get the task by using the returned ID:
gantt.getTask(1405940929703);
returns undefined
And if I look through all tasks, I do find it, with a completely different ID:
gantt.eachTask(function(task){console.log(task.id + " " + task.text);})
returns 145 Test
I would expect the ID returned from an addTask method to be the actual ID, regardless of my data being local or server-side based. Could this be a bug?
Thanks,
Fred S