How to get root parent


How can I get the main project of the task?
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


Hello Arthur,
You can save all parents of the task in an array by using eachParent function:
Then you can show all parents of the task in the reverse mode. Here is an example:

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: