TcxPivotGridField.CollapseAll Method
Collapses all the columns or rows that correspond to the current field.
Declaration
procedure CollapseAll;
Remarks
When the current field is placed within the column header area the CollapseAll method collapses all the grouping columns that correspond to this field. When the current field is placed within the row header area the CollapseAll method collapses all the grouping rows that correspond to this field.
To expand or collapse a specific grouping item (a grouping row or column), you need to locate it within the pivot grid’s display information which is accessible via the ViewData property and set the item’s Expanded property to an appropriate value.
You can set the field’s Options.AlwaysExpanded property to True to expand all the field’s grouping values and keep them expanded, regardless of end-user actions and layout changes.
The following code snippet demonstrates how to collapse the grouping column that corresponds to a grouping value of 1 of the DBPivotGridPurchaseDate field.
var
AGroupItem: TcxPivotGridGroupItem;
begin
// ...
DBPivotGrid.BeginUpdate;
with DBPivotGrid.ViewData do
begin
for I := 0 to ColumnCount - 1 do
begin
AGroupItem := Columns[I].GetGroupItemByField(DBPivotGridPurchaseDate);
if (AGroupItem <> nil) and (AGroupItem.Value = 1) then
begin
AGroupItem.Expanded := False;
break;
end;
end;
end;
DBPivotGrid.EndUpdate;
end;