createTask

adds a new task and opens the lightbox to confirm

string| number createTask( [NewTask task,string | number parent,number index] );
taskNewTaskoptional, the task object
parentstring | numberoptional, the parent's id
indexnumberoptional, the position the task will be added into (0 or greater)
string| numberthe task's id

Example

var taskId = gantt.createTask({
    id:10,
    text:"Task #5",
    start_date:"02-09-2013",
    duration:28
}, "project_2", 2);

Details

If you set the index parameter with the value from 0 and greater, a task will be added to the specified position in the branch. Otherwise, the task will be added to the end of the tasks' branch.

The method invokes the onTaskCreated event. Note, the event fires before the new task is added to the dataset that allows you to cancel saving of this task at all,for example, if the user clicks 'Cancel' button in the lightbox.

The final order of events that fire when you create a task with the createTask() method:

  1. onTaskCreated
  2. onBeforeLightbox
  3. onLightbox
  4. onAfterLightbox
  5. onAfterTaskAdd
  6. onBeforeTaskAdd
See also
Back to top