How to get root parent

Hi,

How can I get the main project of the task?
image
In the column ‘Root’ at ‘NEW TASK’ I want to get ‘Project #1’ besides ‘Task #1’.
How can i do that?
Here the snippet: DHTMLX Snippets

Thx.

Hello Arthur,
You can save all parents of the task in an array by using eachParent function:
https://docs.dhtmlx.com/gantt/api__gantt_eachparent.html
Then you can show all parents of the task in the reverse mode. Here is an example:
http://snippet.dhtmlx.com/13ff9a7a8

Thank you.
Now how can I show only the root “Project#1” instead of both?


Even if I have more level of task I want to show only Project#1 in all of them.

Hello Arthur,
You need to return the last array element:

return parents[parents.length-1];

Here is the snippet:
http://snippet.dhtmlx.com/88f5669fc