2

I'm using a TcxGrid with Grouping. I want to find out how many grouped rows there are but I can't seem to find the right property. There is a <mytableview>.GroupedItemCount but that just refers to how many columns the grid is getting grouped by.

Basically I just want to know if all the groups are collapsed. I could keep a count of expanded groups by watching the GroupRowExpanded and GroupRowCollapsed events but it feels like there should be a better way.

My current plan is to compare the group count with <mytableview>.ViewData.RowCount. If they are different then I must have an expanded group.

I'm guessing the answer is simple.. but the TcxGrid has so many options that I'm not having much luck finding the right one.

Sentient
  • 1,102
  • 12
  • 29
  • Try ".DataController.Groups.GroupingItemCount", but you want to know if there are groups expanded by comparing the amount of groups against the RowCount? If the grid have the same amount of records and groups, whats the point of grouping? – oPsDCadarn Apr 02 '15 at 18:14
  • That seems to be the same value as the `.GroupedItemCount`, or at least it's also coming back as 1 - I'm only grouping by one column. The grid doesn't have same amount of records & groups. If `ViewData.RowCount` is the same as the number of groups then I'll know that all groups are collapsed. The problem is I can't find the number of groups. – Sentient Apr 02 '15 at 18:44
  • It sounds like you use 1-level grouping only (but it is not stated directly in the question). Then probably DataController.Groups.ChildCount[-1] is what you need. If you use hierarchical grouping, then probably you have to enumerate and check all subgroups recursively. – Andrei Galatyn Apr 03 '15 at 09:32

1 Answers1

0

I think you are looking for:

level0GroupCount := gridview.DataController.Groups.ChildCount[-1];

This is the number of data groups at level 0.

To check if every groups are full collapsed:

function AreGridGroupsCollapsed(_gridView : TcxGridDBTableView): Boolean;
var
  level0GroupCount : Integer;
begin
  level0GroupCount := _gridView .DataController.Groups.ChildCount[-1];
  Result := groupCount = _gridView.ViewData.RowCount;
end;
Mattia72
  • 825
  • 1
  • 8
  • 23