1. Domino UI
  2. Data table
  3. Row grouping
Top Grouping Docs

Row grouping

The GroupingPlugin class provides the functionality to group data in a DataTable based on a grouping criteria. It allows expanding and collapsing groups of rows, making it easier to navigate and manage large datasets.

Usage example:

 
 DataTable  dataTable = ... // Create a DataTable instance
 GroupingPlugin  groupingPlugin = new GroupingPlugin< >(new GroupSupplier () {
     {@literal @} Override
     public String getRecordGroupId(TableRow  tableRow) {
         return tableRow.getModel().getCountry(); // Grouping criteria based on the 'country' field
     }
 }, new CellRenderer () {
     {@literal @} Override
     public void render(CellInfo
               cellInfo) { // Custom rendering for the group header cell cellInfo.getElement().textContent = "Group: " + cellInfo.getModel().getCountry(); } }); // Initialize and add the grouping plugin to the DataTable dataTable.addPlugin(groupingPlugin);

T

The data type of the DataTable.

Examples

Row grouping Group a set of rows together.

API Docs: GroupingPlugin

Constructors

public void GroupingPlugin(GroupSupplier<T> groupSupplier, GroupCellRenderer<T> groupRenderer)
Creates a new GroupingPlugin instance with the given group supplier and group renderer.

groupSupplier

The supplier for grouping records.

groupRenderer

The cell renderer for rendering group headers.

Public methods

public void init(DataTable<T> dataTable)
Initializes the grouping plugin and adds it to the DataTable.

dataTable

The DataTable instance to which this plugin will be added.

public GroupingPlugin<T> setGroupExpandedCollapseIcon(Supplier<ToggleIcon<?, ?>> groupExpandedIconSupplier)
Sets the group expanded/collapse icon supplier for the group headers.

groupExpandedIconSupplier

The supplier for the group expanded/collapse icon.



Returns:

This GroupingPlugin instance for method chaining.

public void appendRow(DataTable<T> dataTable, TableRow<T> tableRow)
Appends a row to the DataTable. Handles grouping of rows based on the group criteria.

dataTable

The DataTable instance.

tableRow

The TableRow to append.

public void expandAll()
Expands all groups in the DataTable.
public void collapseAll()
Collapses all groups in the DataTable.
public Map<String, DataGroup<T>> getDataGroups()
Retrieves the data groups created by this plugin.

Returns:

A map of data groups.

public void handleEvent(DominoEvent event)
Handles events triggered on the DataTable.

event

The TableEvent to handle.

We are a group of passionate people who love what we do

Donate & Support Us