Hi,
I’m trying to hook to whatever event is fired when scrolling vertically in the resource panel view. For the horizontal scrolling I can hook to the “onGantScroll” event, but I can’t find the event to plug to for the vertical scrolling.
Additionally, when scrolling in the resource panel view (horizontal or vertical scroll), the “resource_cell_value” function is called. What event fires this call ?
Thanks for your help.
Hello @Nickeau,
The onGanttScroll event is only fired for scrollbars with specific IDs: “scrollVer” (vertical) and “scrollHor” (horizontal).
Since you cannot have multiple scrollbars with the same ID, the resource panel typically uses different IDs (like resourceVScroll for vertical scroll). This means onGanttScroll won’t fire for resource panel scrolling. But you can directly attach an event listener to the resource panel’s scrollbar, as follows:
gantt.attachEvent("onGanttReady", function() {
// Get the resource panel vertical scrollbar by its ID
const resourceScrollbar = gantt.$ui.getView("resourceVScroll");
if (resourceScrollbar) {
resourceScrollbar.attachEvent("onScroll", function(oldPos, newPos, dir) {
console.log("Resource panel scrolled:");
console.log("Old position:", oldPos, "New position:", newPos, "Direction:", dir);
});
}
});
In the onScroll event, parameters are: oldPos (old scroll position), newPos (new scroll position), and dir (scroll direction).
Here’s an example: DHTMLX Snippet Tool.
Regarding this:
Additionally, when scrolling in the resource panel view (horizontal or vertical scroll), the “resource_cell_value” function is called. What event fires this call ?
The resource_cell_value template function is called during scroll as part of the smart rendering mechanism. Gantt redraws only the visible cells to optimize performance that’s why this function is called when scrolling.
Best regards,
Valeria Ivashkevich
DHTMLX Support Engineer