The best way to do this is to:
- Have a count attribute within the entity (I) which is related to the entity (II) that is used in the datagrid
- Use a datasource microflow to retrieve entity I and within that flow retrieve the list of Entity II, count that list and place the value within the count attribute of entity I
- Place a dataview within your page
- Place a groupbox within that dataview
- use the count attribute within the header
- Place the datagrid within that groupbox
That should make it possible :)