DHTMLX Docs & Samples Explorer

Adding Tasks with Script

Basically, you create TaskInfo items, then add them into ProjectInfo, and finally use addProject() of the chart object. All objects are rendered later when you call create() method. This method is usefull when you syncronize the chart with other controls, and much easier is to use XML initialization.

<script>
        var gantt = new GanttChart();
 
        var project_1 = new GanttProjectInfo(1, "Applet redesign", new Date(2006, 5, 11));
        var task_1 = new GanttTaskInfo(1, "Old code review", new Date(2006, 5, 11), 208, 50, "");
        task_1.addChildTask(new GanttTaskInfo(2, "Convert to J#", new Date(2006, 5, 11), 100, 40, ""));
        project_1.addTask(task_1);
        gantt.addProject(project_1);
 
        gantt.create("GanttDiv");
</script>