finds a task by the specified criteria

array getTaskBy(string|function propertyName,string|number|array propertyValue);


propertyNamestring|functionthe name of the property to match, or a filter function
propertyValuestring|number|arraythe property value


arrayarray of task objects


// simple search
var userTasks = gantt.getTaskBy("user_id", [5]);
// (task: object) => boolean
var userTasks = gantt.getTaskBy(function(task){
   return task.user_id == 5 || !task.user_id;
var userTasks = gantt.getTaskBy(task => task.user_id == 5);

Related samples

  • The method can be used for selecting tasks by the property value, e.g. find tasks of a specific user, find completed tasks, etc.
  • Tasks of the project type are not iterated.
  • gantt.getTaskBy(propertyName, propertyValue) uses loose equality check ("double equals", ==)
  • The result of gantt.getTaskBy(propertyName, propertyValue) can be cached by gantt, thus this overload can work faster than gantt.getTaskBy((task: object) => boolean)
See also
Back to top