getTaskBy
finds a task by the specified criteria
array getTaskBy(string|function propertyName,string|number|array propertyValue);
Parameters
propertyName | string|function | the name of the property to match, or a filter function |
propertyValue | string|number|array | the property value |
Returns
array | array of task objects |
Example
// 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
Details
- 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