Search results

Change Schedule Dates in ASP.NET MVC Gantt control

In the Gantt control, you can change the schedule start and end dates by clicking the custom button programmatically using the updateProjectDates method. You can pass the start and end dates as method arguments to the updateProjectDates method. You can also pass the Boolean value as an additional parameter, which is used to round-off the schedule start and end dates displayed in Gantt timeline.

razor
changeScheduleDates.cs
@Html.EJS().Button("updateSchedule").Content("Update Schedule").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("updateSchedule").addEventListener('click', () => {
             var ganttObj = document.getElementById("Gantt").ej2_instances[0];
             ganttObj.updateProjectDates(new Date('01/10/2019'), new Date('06/20/2019'), true);
          });
		</script>
public IActionResult Index()
{
    ViewBag.DataSource = GanttData.ProjectNewData();
    return View();
}