How can I modify the data and output a new JSON?


#1

I had use gantt.parse(aJsonObj) to build a chart.
How can I let users modify the data (e.g. change start_time or text ) and then output a new JSON file?
Is there any chapter talk about this?


#2

Hello,
Gantt can work only on the frontend part and doesn’t have access to files.
You can only save all your data to a JSON variable then you can use that variable to save it to a file.
To save the data to a variable, you can use gantt.serialize() command:
https://docs.dhtmlx.com/gantt/api__gantt_serialize.html
Here is an example of how it might be implemented using Gantt API + Javascript:
http://snippet.dhtmlx.com/e80db036d


#3

Thanks!
It’s very helpful.

But if my tasks have many custom properties.
Can I define them in the lightbox to make some change?

For example : my data have these properties { id, text, start_date, end_date, location, color, length }
The default lightbox can work on the text and time,
but I want users can also use the lightbox to modify “location”, “color” and “length” properties.


#4

Hello,
Yes, you can modify custom properties from the lightbox.
But first, you need to decide which element type you want to use to update the value.
For example, you can use the “Select” control to display drop-down lists.
Here are two snippets where you can see how it might be implemented:
https://snippet.dhtmlx.com/734133b8b
https://snippet.dhtmlx.com/6d7c5dbdf
And you can check our samples with the lightbox customization:
https://docs.dhtmlx.com/gantt/samples/05_lightbox/