Search code examples
delphidelphi-xe2tcxgrid

Show grouped record count in group heading on tcxgrid


I have a form with a cxgrid on it and I have allowed grouping on the grid.

When I drag and drop column into the group section, instead of it just displaying the column name, is there a way for it to also include the record count for that grouping?

example of group:

enter image description here

Status is a column on the grid which has multiple statuses. So after Active/Closed it would have the record count for that status.


Solution

  • In the Object Inspector

    • click your cxGridDBTableView1
    • in the Summary sub-property, click the button to the right of DefaultGroupSummaryItem
    • in the pop-up set Kind to skCount

    That's it.

    To a certain extent, you can customize how the Summary (group) rows are displayed by adjusting properties in the OI. It that isn't sufficient, you can I believe draw the group cells yourself in the

    cxGrid1DBTableView1CustomDrawGroupCell
    

    event. But that would involve finding your way around the objects passed to it, in particular the AViewInfo object.