<button id="updateData">Update Data</button>
var ganttChart = new ej.gantt.Gantt({
dataSource: projectNewData,
height: '450px',
allowSelection: true,
//..
});
document.getElementById('updateData').addEventListener('click', () => {
var GanttData = [
{
TaskID: 1,
TaskName: 'Project Initiation',
StartDate: new Date('04/02/2019'),
EndDate: new Date('04/21/2019'),
subtasks: [
{ TaskID: 2, TaskName: 'Identify Site location', StartDate: new Date('04/02/2019'), Duration: 4, Progress: 50 },
{ TaskID: 3, TaskName: 'Perform Soil test', StartDate: new Date('04/02/2019'), Duration: 4, Progress: 50 },
{ TaskID: 4, TaskName: 'Soil test approval', StartDate: new Date('04/02/2019'), Duration: 4, Progress: 50 }
]
}
];
setTimeout(function () {
ganttChart.dataSource = GanttData; // Binding new dataSource
}, 1000)
});
|
I have error :
Cannot read property 'toString' of null
when use "ganttChart.dataSource = GanttData; "
var ganttChart = new ej.gantt.Gantt({
dataSource: projectNewData,
height: '450px',
allowSelection: true,
taskFields: {
id: 'TaskID',
name: 'TaskName',
startDate: 'StartDate',
endDate: 'EndDate',
duration: 'Duration',
progress: 'Progress',
dependency: 'Predecessor',
child: 'subtasks'
},
//..
});
document.getElementById('updateData').addEventListener('click', () => {
var GanttData = [
{
TaskID: 1,
TaskName: 'Project Initiation',
StartDate: new Date('04/02/2019'),
EndDate: new Date('04/21/2019'),
subtasks: [
{ TaskID: 2, TaskName: 'Identify Site location', StartDate: new Date('04/02/2019'), Duration: 4, Progress: 50 },
{ TaskID: 3, TaskName: 'Perform Soil test', StartDate: new Date('04/02/2019'), Duration: 4, Progress: 50 },
{ TaskID: 4, TaskName: 'Soil test approval', StartDate: new Date('04/02/2019'), Duration: 4, Progress: 50 }
]
}
];
setTimeout(function () {
ganttChart.dataSource = GanttData; // Binding new dataSource
}, 1000)
});
|