How to scrol to today even when projects start 10 days after

Hello,

We have purchased Gantt 3.1.0 licences today and we have started developing and have encountered an issue.

We currently use :

var scrollX = gantt.posFromDate(new Date("2014/11/27")); gantt.scrollTo(scrollX, 0);

However if there are no projects before / after this date it scrolls to the first project instead.

Is there a way to make sure that it’s always possible to scroll to a date ?

Another issue we have is the yearly view centers the projects, and we would like to always have today about 10px from the left. Is this possible ?

Thanks

Hi,
by default gantt scrolls to the first scheduled task when the data is loaded.
You can disable this behavior with initial_scroll config and manually scroll gantt to the required date when the data is loaded:

gantt.config.initial_scroll = false; gantt.attachEvent("onLoadEnd", function(){ gantt.showDate(new Date(2014, 10, 27)); });
docs.dhtmlx.com/gantt/api__gantt_showdate.html
docs.dhtmlx.com/gantt/api__gantt … onfig.html
docs.dhtmlx.com/gantt/api__gantt … event.html

If you mean the offset that is added to the scale before and after first and last tasks when the time range is not specified - docs.dhtmlx.com/gantt/samples/03 … _year.html - then no, it can’t be removed. Gantt always adds such padding when daterange is calculated automatically. You can specify the displayed date range explicitly using these configs
docs.dhtmlx.com/gantt/api__gantt … onfig.html
docs.dhtmlx.com/gantt/api__gantt … onfig.html