The rows can be grouped on a specific field in such a way that rows can be expanded and collapsed using row expander feature. This feature is enabled by setting rowGroupMode="subheader", expandableRowGroups="true", and groupField="browser". groupField is set to a specific categorized column.
The row grouping feature with expandable row group option would be written as follows:
<p-dataTable [value]="browsers" sortField="browser"
rowGroupMode="subheader" groupField="browser"
expandableRowGroups="true" [sortableRowGroup]="false">
<p-header>Toggleable Row Groups with Footers</p-header>
<ng-template pTemplate="rowgroupheader" let-rowData>
{{rowData['browser']}}
</ng-template>
<p-column field="engine" header="Engine"></p-column>
<p-column field="platform" header="Platform...