RowGroup
The ability to group rows in a table can let an end user quickly and easily see the structure of the data shown, and also present them with summaries of the data shown in each group. RowGroup adds this ability to DataTables with the ability to customise the start and end grouping rows displayed in the DataTable, letting you integrate the summarised data to fit perfectly in with your site.
Download
The easiest way to get and use RowGroup is to use the DataTables download builder where you can select the software that you wish to use on your page and have a single Javascript and CSS file created and hosted for you.
Alternatively, the individual files can be included on your page, a release package downloaded, NPM package or the source control repository cloned on GitHub.
Initialisation
RowGroup can be initialised on a DataTable by using the rowGroup
option in the DataTables options object. In most circumstances you will wish to also set the rowGroup.dataSrc
option to tell DataTables which data point in the data source to use for initial grouping. Other options can also be set - see the reference documentation for full details:
$('#myTable').DataTable( {
rowGroup: {
dataSrc: 'group'
}
} );
Features
RowGroup adds the following features to DataTables:
- Grouping of data
- Customisable renderers for the grouping start and / or end row
- API to dynamically change the grouping data point
- API to dynamically enable and disable this feature
- Full integration with Bootstrap, Foundation and the other styling libraries supported by DataTables
Limitations and future work
The features offered by RowGroup are useful, but also also limited in several aspects. The following limitations are known and will be topics for future updates (there is no time for these features yet):
- No option to expand / collapse a group
- Currently only a single data point can be used for grouping at a time - there is no support for nested grouping
- Click and drag column headers to group
- No support for the export options of the Buttons extension - the grouping information is just ignored
- No support for the Scroller extension.
Please see the compatibility chart for further information.