- Регистрация
- 9 Май 2015
- Сообщения
- 1,480
- Баллы
- 155
When working with large projects, finding the right tasks in a Gantt Chart can be challenging. Without the right tools, it can be difficult to focus on what matters most. Thats why the introduces two powerful features:
Together, these features give you full control over how tasks are displayed.
Task Filtering
At the core of filtering is the logic in theTTMSFNCGanttChartFilter class. It allows you to build filter expressions programmatically. You can add simple or complex conditions, combine them with AND and OR.
Building Filters
To use filtering, your refer to the different property names that are used for the columns to automatically fill in the Gantt Chart List and these are: wbs, taskname, taskdescription, startdate, enddate, duration, statename, progress, cost, dependencies, datastring, datainteger, databoolean.
begin
TMSFNCGanttChart.Filter.AddAND('taskname', feoStartsWith, 'D');
TMSFNCGanttChart.Filter.AddAND('progress', feoSmallerThan, 50);
end;
Another way is to set the filter via :
begin
// Default format: TMSFNCGanttChart1.Filter.FormatType := fftDelphiDataSet;
TMSFNCGanttChart1.Filter.Parse('[taskname] LIKE ''D%'' AND [progress] < 50');
TMSFNCGanttChart1.Filter.FormatType := fftUniversalFilterExpressions;
TMSFNCGanttChart1.Filter.Parse('[taskname] = "D*" & [progress] < 50');
end;
Managing Filters
You can quickly reset a filter with the Clear procedure.
It is easy to check whether you are already filtering on a given property with the HasFilter function, and to clear all of the expressions that are using a given property name via RemovePropertyFilter.
Filter Hierarchy Mode
Filtering also defines how the hierarchy around filtered tasks is displayed. For this, we use the FilterHierarchyMode property:
Visual examples for tasks starting with "D":
Parent Hierachy:
Children Hierarchy:
Both Hierarchy:
Strict Hierarchy:
Task Sorting
You can also sort tasks. This is done on a project level. And changes the position of the tasks in the collection.
The sorting works with the property names, in the same way as the filtering and column names. (wbs, taskname, taskdescription, startdate, enddate, duration, statename, progress, cost, dependencies, datastring, datainteger, databoolean.)
The sorting can be enabled on the Column property of the Gantt Chart which will trigger when clicking on the header of the Gantt List Column. Or programmatically with the sort method.
GanttChart.Project.Sort(
'wbs', // Property to sort on
True, // Recurse into subtasks
True, // Case-sensitive
True // Ascending order
);
(
When sorting tasks, the custom WBSPart will be filled with the current index to ensure that the data is displayed as expected.)
Conclusion
The now provides a rich set of tools for filtering and sorting tasks. Whether you want to zoom in on specific conditions, maintain context with parents or children, or reorder tasks by date, name, or WBS you are in full control of how project data is presented.
With these features combined, managing even the most complex projects becomes intuitive and efficient.
Together, these features give you full control over how tasks are displayed.
Task Filtering
At the core of filtering is the logic in theTTMSFNCGanttChartFilter class. It allows you to build filter expressions programmatically. You can add simple or complex conditions, combine them with AND and OR.
Building Filters
To use filtering, your refer to the different property names that are used for the columns to automatically fill in the Gantt Chart List and these are: wbs, taskname, taskdescription, startdate, enddate, duration, statename, progress, cost, dependencies, datastring, datainteger, databoolean.
begin
TMSFNCGanttChart.Filter.AddAND('taskname', feoStartsWith, 'D');
TMSFNCGanttChart.Filter.AddAND('progress', feoSmallerThan, 50);
end;
Another way is to set the filter via :
begin
// Default format: TMSFNCGanttChart1.Filter.FormatType := fftDelphiDataSet;
TMSFNCGanttChart1.Filter.Parse('[taskname] LIKE ''D%'' AND [progress] < 50');
TMSFNCGanttChart1.Filter.FormatType := fftUniversalFilterExpressions;
TMSFNCGanttChart1.Filter.Parse('[taskname] = "D*" & [progress] < 50');
end;
Managing Filters
You can quickly reset a filter with the Clear procedure.
It is easy to check whether you are already filtering on a given property with the HasFilter function, and to clear all of the expressions that are using a given property name via RemovePropertyFilter.
Filter Hierarchy Mode
Filtering also defines how the hierarchy around filtered tasks is displayed. For this, we use the FilterHierarchyMode property:
Mode | Description |
---|---|
gfhParent | Shows matching tasks and their parents, keeping the full context. (Default value.) |
gfhChildren | Shows matching tasks and all of their children (subtree). |
gfhBoth | A combination of Parent and Children. |
gfhStrict | Shows only the tasks that match the filter. |
Visual examples for tasks starting with "D":
Parent Hierachy:

Children Hierarchy:

Both Hierarchy:

Strict Hierarchy:

Task Sorting
You can also sort tasks. This is done on a project level. And changes the position of the tasks in the collection.
The sorting works with the property names, in the same way as the filtering and column names. (wbs, taskname, taskdescription, startdate, enddate, duration, statename, progress, cost, dependencies, datastring, datainteger, databoolean.)
The sorting can be enabled on the Column property of the Gantt Chart which will trigger when clicking on the header of the Gantt List Column. Or programmatically with the sort method.
GanttChart.Project.Sort(
'wbs', // Property to sort on
True, // Recurse into subtasks
True, // Case-sensitive
True // Ascending order
);
(

Conclusion
The now provides a rich set of tools for filtering and sorting tasks. Whether you want to zoom in on specific conditions, maintain context with parents or children, or reorder tasks by date, name, or WBS you are in full control of how project data is presented.
With these features combined, managing even the most complex projects becomes intuitive and efficient.
Источник: