Hello Janani,
i created database table for resources. i want to know how to load the data from that table into a variable using php . please guide me for this
Unfortunately, I don’t specialize in PHP, so I won’t be able to suggest to you how to load the data from the server-side to a JSON variable.
its for group level. i created table name as gantt_emp and emp.php in this file fetch emp details from db and echo json_encode($res);
in front end
using gantt.load (emp.php);
it throw error.
You need to load the resource data with the resourcesStore.parse(your_variable)
command. You cannot load it another way.
If you want to load the gantt data altogether with the resource data, you need to put the resource data into a collection
:
https://docs.dhtmlx.com/gantt/desktop__supported_data_formats.html#jsonwithcollections
To make it work correctly, first, you need to create a collection with that name, then load the data.
When you use the gantt.load()
and gantt.parse()
commands, Gantt expects to load tasks and links, then additional properties. If you try parsing only the additional properties, it won’t work. In that case, you need to specify the data
and links
without objects, for example:
gantt.serverList("resource_data");
gantt.parse({
"data": [],
"links": [],
"collections": {
"resource_data":[
{id: 1, text: "QA", parent:null},
{id: 2, text: "Development", parent:null},
{id: 3, text: "Sales", parent:null},
{id: 4, text: "Other", parent:null},
{id: 5, text: "Unassigned", parent:4},
{id: 6, text: "John", parent:1},
{id: 7, text: "Mike", parent:2},
{id: 8, text: "Anna", parent:2},
{id: 9, text: "Bill", parent:3},
{id: 10, text: "Floe", parent:3}
]
}
})
However, you still need to use the resourcesStore.parse()
command to load the resource data, although, now you can use the collections:
resourcesStore.parse(gantt.serverList("resource_data"));
Here is the snippet that demonstrates how it works:
http://snippet.dhtmlx.com/b21bb6b28