Click task to locate the resource

Hi! When I click on the task, can I display the first resource according to the array of resources bound to the job?

Hello,
When you click on a task in the grid, Gantt scrolls the timeline to show the task bar.
If the resource timeline uses the same scrollbar as the main timeline, it means that the resource timeline will be scrolled horizontally to the same position.
If you want to scroll it vertically, you need to implement a custom solution by using the Gantt API and Javascript.
You can scroll the resource timeline by using the scrollLayoutCell method:
https://docs.dhtmlx.com/gantt/api__gantt_scrolllayoutcell.html

Here is an example of how it can be implemented:

image
When I use this method, it says it’s not a functional method?

Hello,
It seems that you don’t have the latest version. This method was added in the 8.0.0 version.
So, instead of that, you need to use the internal API to get the same functionality.

First, you need to get the scrollbar that is relevant to the layout cell you want to scroll by using the gantt.$ui.getView method. Then, you need to use the scrollTo method to scroll the scrollbar, then the layout cell will be scrolled.

For example, in the following snippet, you need to call the following code to scroll the resource timeline vertically:

gantt.$ui.getView("resourceVScroll").scrollTo(null,100)

https://snippet.dhtmlx.com/2c4sfnni

onGanttScroll Whether the event is triggered before the onTaskSelected event

Hello,
When you click to select a task in the Gantt chart, the scroll state of the Gantt chart is initialized with its current position, triggering the ‘onGanttScroll’ event. After the task is selected, the Gantt chart will scroll to the selected task at its new position, causing the scroll state to be updated.

Yes, you can, by using event handlers or custom code to fetch and show the first resource when the task is clicked. Configure your Gantt chart to trigger a display or update function that retrieves and shows the first resource from the array associated with the clicked task.