Support sticky dates on scale cell


#1

like the video above, could you guys support the sticky date on scale cell or layout? that we we could let user know which big scale date are they on ,for example they should know current dates is on May or June.

If dhtmlx gantt doesn’t have any official API for these, could I achieve this by some combinetions of operation?if you could achieve this, could you provide a demo to me? thanks


#2

Hi @kevinyaoooooo !

There is no built-in option for this, but you can inject a custom DOM element into the gantt container, place it over the time scale and display a visible date there each time gantt repaints or scrolls.

Use onGanttScroll to detect when gantt is scrolled.
https://docs.dhtmlx.com/gantt/api__gantt_onganttscroll_event.html

Use getScrollState() method to get current the scroll position:
https://docs.dhtmlx.com/gantt/api__gantt_getscrollstate.html

dateFromPos() method gets the date of the specified horizontal position in the chart area.
https://docs.dhtmlx.com/gantt/api__gantt_datefrompos.html

And put the formatted date into the custom element over the time scale

Here is a sample, where you can see how it can be done: