add

Fired when a new task or a new dependency is about to be added.

The event handler function context (available via the this keyword) will be set to the widget instance.

Event Data

e.task kendo.data.GanttTask

The GanttTask instance which will be added to the DataSource.

e.dependency kendo.data.GanttDependency

The GanttDependency instance which will be added to the DataSource.

e.preventDefault Function

If invoked prevents the add action.

e.sender kendo.ui.Gantt

Example - subscribe to the "add" event during initialization

<div id="gantt"></div>
<script>
$("#gantt").kendoGantt({
  dataSource: [
    {
      id: 1,
      orderId: 0,
      parentId: null,
      title: "Task1",
      start: new Date("2014/6/17 9:00"),
      end: new Date("2014/6/17 11:00")
    }
  ],
  add: function(e) {
/* The result can be observed in the DevTools(F12) console of the browser. */
    console.log("Add", e.task.title);
  }
});
</script>

Example - subscribe to the "add" event after initialization

<div id="gantt"></div>
<script>
function gantt_add(e) {
/* The result can be observed in the DevTools(F12) console of the browser. */
  console.log("Add", e.task.title);
}
$("#gantt").kendoGantt({
  dataSource: [
    {
      id: 1,
      orderId: 0,
      parentId: null,
      title: "Task1",
      start: new Date("2014/6/17 9:00"),
      end: new Date("2014/6/17 11:00")
    }
  ]
});
var gantt = $("#gantt").data("kendoGantt");
gantt.bind("add", gantt_add);
</script>
In this article