Quantcast
Channel: Telerik Forums RSS
Viewing all articles
Browse latest Browse all 84751

Scroll to current day

$
0
0
Hi,

Thank you for clarifying.

You can use the following javascript to scroll to the current date:
function pageLoad() {
    $find("RadGantt1")._widget.bind("dataBound", ganttDataBound);
}
 
function ganttDataBound() {
    var view = $find("RadGantt1")._widget.timeline.view();
    var viewStart = view.start;
    var viewEnd = view.end;
    var currentDate = new Date();
 
    if (currentDate > viewStart && currentDate < viewEnd) {
        var offset = view._offset(currentDate);
 
        // decrease the offset by some amount, so that
        // the current day indicator is not right next
        // to the splitter
        offset -= 100;
 
        view.content.scrollLeft(offset);
    }
}

One thing to keep in mind is that the gantt may not always show the current date. The range shown in the timeline is determined by the loaded tasks, and if the tasks are all before or after the current date, it won't be visible. This behavior is by design and cannot be changed.

Regards,
Bozhidar
Telerik

Viewing all articles
Browse latest Browse all 84751

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>