Search results

Set Scroll Top in ASP.NET Core Gantt control

15 Oct 2021 / 1 minute to read

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

tagHelper
setScrollTop.cs
Copied to clipboard
<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>
Copied to clipboard
public IActionResult Index()
{
    ViewBag.DataSource = GanttData.ProjectNewData();
    return View();
}

Alt text