Empty gantt object, empty gantt.serialize but render Ok.

I am just started with dhtmlx gantt and I have a problem:
1- I get the dhtmlx.gantt working like a charm. It updates and saves to MySQL database, where I can list and see the new tasks and delete existing tasks.
2- When I want to manipulate a task, say, change the text or date, retrieving the information from the json object, it is empty.

gantt.config.xml_date = "%Y-%m-%d %H:%i"; gantt.init("gantt_here"); gantt.load("data.php");//loads data to Gantt from the database var dp = new gantt.dataProcessor("data.php"); dp.init(gantt); retrieved = gantt.serialize().tasks; console.log(retrieved); var task = gantt.getTask(2); console.log(task);

When I load the data.php on the browser, I get the full data:

{ “data”:[{“id”:“1”,“start_date”:“2013-04-01 00:00:00”,“duration”:“11”,“text”:“Um”,“progress”:“0.6”,“sortorder”:“1”,“parent”:“0”},{“id”:“2”,“start_date”:“2013-04-03 00:00:00”,“duration”:“5”,“text”:“Dois”,“progress”:“1”,“sortorder”:“2”,“parent”:“1”},{“id”:“3”,“start_date”:“2013-04-02 00:00:00”,“duration”:“7”,“text”:“Tres”,“progress”:“0.5”,“sortorder”:“0”,“parent”:“1”},{“id”:“4”,“start_date”:“2013-04-03 00:00:00”,“duration”:“2”,“text”:“Quatro”,“progress”:“1”,“sortorder”:“0”,“parent”:“3”},{“id”:“5”,“start_date”:“2013-04-04 00:00:00”,“duration”:“3”,“text”:“Cinco”,“progress”:“0.8”,“sortorder”:“0”,“parent”:“3”},{“id”:“6”,“start_date”:“2013-04-05 00:00:00”,“duration”:“4”,“text”:“Seis”,“progress”:“0.2”,“sortorder”:“0”,“parent”:“3”}], “collections”: {“links”:[{“id”:“1”,“source”:“1”,“target”:“2”,“type”:“1”},{“id”:“2”,“source”:“1”,“target”:“3”,“type”:“1”},{“id”:“3”,“source”:“3”,“target”:“4”,“type”:“1”},{“id”:“4”,“source”:“4”,“target”:“5”,“type”:“0”},{“id”:“5”,“source”:“5”,“target”:“6”,“type”:“0”}]}}

But when I want to see the gantt.getTask(2), it returns undefined.

It puzzles me, for the data.php and rendering of the gantt chart shows it has the data I want to see. Where is it?

Please help.

Ed

I forgot to send the data.php

[code]<?php

include (‘dhtmlxGantt/codebase/connector/gantt_connector.php’);

$dbtype = “MySQL”;
$res=mysql_connect(“192.168.1.201”,“root”,“albedo”);
mysql_select_db(“gantt”);

$gantt = new JSONGanttConnector($res);
$gantt->render_links(“gantt_links”,“id”,“source,target,type”);
$gantt->render_table(
“gantt_tasks”,
“id”,
“start_date,duration,text,progress,sortorder,parent”
);
?>[/code]

And there is a red error message that says:
“Task not found id=2”
And the console.log response is undefined.

Thanks

Hello,
gantt.load is async operation, which means that the data is not yet received when the next line of code is executed.
You need to use either a callback argument or onLoadEnd event
docs.dhtmlx.com/gantt/api__gantt_load.html

Dear Aliaksandr,

It was exactly that.

Now I can move on with the project.

Spatsibó.

Eduardo