How to get data from Gantt page?

Hi,
I can test DHX Gantt some data on the page and modify couple of date and durations on the web page.
Well, How can get the data from the Gantt. If I get the new gantt values again than I can save them in PostgreSQL database back again?

Regards,
Mucip:)

Hello Mucip,
Gantt is a client-side library. It doesn’t directly communicate with the database or the server-side. All changes occur only inside the browser.

To load the data, you can use the gantt.load or gantt.parse methods:
https://docs.dhtmlx.com/gantt/api__gantt_load.html
https://docs.dhtmlx.com/gantt/api__gantt_parse.html

To send the changes to the server, you need to use the Data Processor or built-in Ajax module. You can read more about it in the following articles:
https://docs.dhtmlx.com/gantt/desktop__server_side.html
https://docs.dhtmlx.com/gantt/api__gantt_ajax_other.html

Here are examples:
http://snippet.dhtmlx.com/41d5ffad3
http://snippet.dhtmlx.com/5/d0b0020f8

Dear Ramil,
When I tested your code it creates something like below,
resim

Infact If we can create something like csv string than I can send it via Ajax code to other PHP file?

Do you have any sample for this please?

Regards,
Mucip:)

Hello Mucip,
Gantt doesn’t work with CSV strings. If you need that format, you need to manually convert the JSON data to a CSV string when you save the data and convert CSV string to JSON when you load the data.
There are no ready examples of the implementation

But you can check the following pages that can help you to start implementing your solution:

Hi,
I saw many functions and Procedures in jason data and I don’t know why?
Where is data in Json? How can I get the gantt data.

By the way I will check the links which your sent?

Regards,
Mucip:)

Hello Mucip,
Thank you for the clarification.
It seems that you decided to open the [[Prototype]] property of the Javascript’s array. You will find the same properties in any arrays.
The actual array is empty. It seems you just clicked on a button without making any changes.
If you drag a task and click on the button, the array will have the values:
https://files.dhtmlx.com/30d/b468b0fa9169fab3d9fc09ee3532226e/vokoscreen-2024-08-30_19-30-08.mp4

Dear Ramil,
Thanks for your kind interest.
I think I can see only affected task’s values.
But How can I get all tasks information like csv file or detail information like “Task name, ID, Duration” etc.?
Regards,
Mucip:)

Hello Mucip,
When a task is updated, Gantt doesn’t send the changes only of the updated properties. Instead, it sends the whole task object:
https://files.dhtmlx.com/30d/791355c014703b141789b162ae0ef944/vokoscreen-2024-09-03_12-39-25.mp4

If you want to get all tasks and links with the stringified dates, you can use the serialize method:
https://docs.dhtmlx.com/gantt/api__gantt_serialize.html

1 Like

Dear Ramil,
That is what I asking for:

var infoBack = gantt.serialize(‘xml’);

I can send this variable to PHP with Ajax and parse/save back to database I guess
 :wink:

Thanks a lot.

Regards,
Mucip:)