Showing Delay Drivers in Gantt

Hi, I have a requirement to show “delay drivers” in the Gantt Chart. The logic is if I select a specific task/milestone from the lists of tasks/milestones present in the gantt, I want the system to show me the tasks which are driving the selected task.(i.e.; if any of those tasks delayed my selected task/milestone will get delayed). In order to delay the specific task/milestone selected it has to be dependent. I already have the logic done in the backend and I am trying the plot the data in the dhtmlx gantt and it plots well.

Now I want to reverse the gantt, I want the selected specific task to be last.

Check out this example,

https://snippet.dhtmlx.com/0g7hmkow

In the example you can see the if I click the start time, it wont sort because of the dependency, What I want is that the selected specific milestone will be the task the gantt end with all its dependent tasks will be above it.

Hello,
The sorting you’re trying to achieve doesn’t work as expected because each task is a child of the previous one. However, you can override the getItemTop method to manually set the required task position. Here’s an example of how to do that:

gantt.attachEvent('onGanttReady', () => {
    gantt.$ui.getView('grid').getItemTop = (taskId) => {
        const task = gantt.getTask(taskId);
        const taskOrder = task.order;
        const totalTasks = gantt.getTaskCount();
        const reversedOrder = totalTasks - taskOrder;

        return reversedOrder * 35;
    };

    gantt.$ui.getView('timeline').getItemTop = (taskId) => {
        const task = gantt.getTask(taskId);
        const taskOrder = task.order;
        const totalTasks = gantt.getTaskCount();
        const reversedOrder = totalTasks - taskOrder;

        return reversedOrder * 35;
    };
});

Please see an example: DHTMLX Snippet Tool