calculateTaskLevel

calculates the level of a task

number calculateTaskLevel(object task);

Parameters

taskobjectthe task's object

Returns

numberthe level of a task in the tree hierarchy (zero-based numbering)

Example

gantt.attachEvent("onTaskCreated", function(task){
 var level = gantt.calculateTaskLevel(task),
   types = gantt.config.types;
 
 //assign task type based on task level
 switch (level){
  case 0:
   task.type = types.project;
   break;
  case 1:
   task.type = types.subproject;
   break;
  default:
   task.type = types.task;
   break;
 }
 return true;
});

See also
Back to top