AutoScroll to DateTime.Now()

Hi! 

Is there a way to scroll the diagram into position so I have "Today" in the center of my View? 


3 Replies

AK Alagumeena Kalaiselvan Syncfusion Team February 10, 2022 01:14 PM UTC

Hi Brandon , 
 
Yes , we can able to display the today date in current view using scrollToDate() method in dataBound event.  In the shared work around we have set a project start date as December 25 2021, but the view starts from feburary, because we are passing today date in the scrollToDate() method. We have also display an eventmarker in todays date for highlight the todays date.  
 
Code snippets: 
 
dataBound(args) { 
    var today = new Date(); 
    this.ganttInstance.scrollToDate(today); 
  } 
 
 
Please contact us for further assistance. 
  
Regards, 
Premkumar S 



BR Brandon February 10, 2022 08:02 PM UTC

Thank you!! It works perfectly
I have another question, is it possible to scroll vertically to a specific task? 

For example I have 100 tasks in my Gantt component but i want to scroll to my task #60 





MS Monisha Sivanthilingam Syncfusion Team February 11, 2022 08:44 AM UTC

Hi Brandon, 
 
You are welcome. 
 
Yes, it is possible to scroll vertically to a particular task by using the selectRow method. We have modified the sample we shared previously to scroll to a particular record at load time itself. The below code snippets demonstrate the solution. 
 
Index.js 
 
dataBound(args) { 
  var today = new Date(); 
  this.ganttInstance.scrollToDate(today); 
  this.ganttInstance.selectionModule.selectRow(10, true, true); 
} 
 
 
 
Please contact us if you require any further assistance. 
 
Regards, 
Monisha. 


Loader.
Up arrow icon