Change schedule start and end dates

17 Feb 20222 minutes to read

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.

<ejs-button id="updateSchedule" content="Update Schedule" 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('updateSchedule').addEventListener('click', function (args) {
            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();
}