Grouping Basics

The KendoReact Data Grid enables you to display grouped table data.

ninja-iconThe Grouping is part of KendoReact, a professional grade UI library with 110+ components for building modern and feature-rich applications. To try it out sign up for a free 30-day trial.Start Free Trial

Getting Started

To enable grouping:

  1. Set the groupable and group options of the Grid.
  2. Handle the onGroupChange or the emitted onDataStateChange event. The onDataStateChange event is recommended when the Grid will have other data operations as it provides the complete dataState in a single event.
  3. Group the data on the client by using our built-in methods groupBy or process. The data can also be grouped on the server by making a request using the event parameters. The Grid expects the grouped data to be a collection of GroupResults.

The groupBy method is recommended when using the onGroupChange event, and the process method is recommended when using the onDataStateChange event.

For more information, refer to the article on the process helpers for bulk data operations.

Change Theme
Theme
Loading ...

Grouping Columns Dynamically

By default, all columns of the Grid can be grouped multiple times. To enable the grouping of specific Grid columns and implement dynamic grouping to a column, use a function or a variable for the groupable property.

jsx
<Column field="ProductID" filterable={false} title="ID" width="50px" groupable={isGroupable("ProductID")} />
jsx
const [group, setGroup] = React.useState<GroupDescriptor[]>(initialGroup);

const isGroupable = (field) => {
    return !((group || []).find((g) => g.field === field));
}

Persist Groups Collapsed State

The data-tools package provides few utility methods which can be used to generate unique group items ids and use them to persist the group collapsed state.

Change Theme
Theme
Loading ...

Expand and Collapse all groups

The example below shows how to add a button that expands or collapses all groups in the Grid.

Change Theme
Theme
Loading ...