Set the vertical scroll position

8 Nov 20221 minute to read

In the Gantt control, you can set the vertical scroller position dynamically by clicking the custom button using the setScrollTop method.

<ejs-button id="setScrollTop" content="Change Scroll Position" cssClass="e-primary"></ejs-button>
                <ejs-gantt id='Gantt' dataSource="ViewBag.DataSource" height="450px">
                    <e-gantt-taskfields id="TaskId" name="TaskName" startDate="StartDate"
                          endDate="EndDate" duration="Duration" progress="Progress" child="SubTasks">
                    </e-gantt-taskfields>
                </ejs-gantt>
				
	<script>
        document.getElementById('setScrollTop').addEventListener('click', function (args) {
            var ganttObj = document.getElementById('Gantt').ej2_instances[0];
            ganttObj.ganttChartModule.scrollObject.setScrollTop(300);
        });
    </script>
public IActionResult Index()
{
    ViewBag.DataSource = GanttData.ProjectNewData();
    return View();
}

Alt text