Search results

Set Scroll Top in ASP.NET MVC Gantt control

28 Jul 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.

razor
setScrollTop.cs
Copied to clipboard
@Html.EJS().Button("setScrollTop").Content("Change Scroll Position").CssClass("e-primary").Render()
        @Html.EJS().Gantt("Gantt").DataSource((IEnumerable<object>)ViewBag.DataSource).Height("450px").TaskFields(ts =>
         ts.Id("TaskId").Name("TaskName").StartDate("StartDate").EndDate("EndDate").Duration("Duration").Progress("Progress").Child("SubTasks")
         ).Render()
        
	  <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