Remove the "Select all" checkbox in the Grid's header for checkbox selection
Environment
| Product Version | 16.1.0 |
| Product | Progress® KendoReact Grid |
Description
I want to remove the "Select all" checkbox in the Grid's header when using checkbox selection.
This KB also answers the following questions:
- How do I remove or hide the "Select all" checkbox from the KendoReact Grid header?
- How can I keep row-level checkbox selection while removing the header checkbox?
- How do I customize the checkbox column header with the current
cells.headerCellAPI?
Solution
Use the cells.headerCell property to customize the header cell of the checkbox column. Register the custom header cell on the Column with columnType="checkbox", then render the HeaderThElement with the provided thProps and leave out props.children. This removes the built-in "Select all" checkbox while preserving the default row checkbox cells.
Leaving out
props.childrenalso removes the default header content for that column, such as the resize handle.
Registering the custom header cell on the checkbox column limits the customization to that column, as shown in the following snippet:
import { HeaderThElement } from '@progress/kendo-react-data-tools';
import { GridColumn as Column, GridCustomHeaderCellProps } from '@progress/kendo-react-grid';
const EmptyHeaderCell = (props: GridCustomHeaderCellProps) => (
<HeaderThElement columnId={props.thProps?.columnId || ''} {...props.thProps} />
);
<Column columnType="checkbox" cells={{ headerCell: EmptyHeaderCell }} />
For more information about the available props, see GridCustomHeaderCellProps.
The following example demonstrates how to remove the "Select all" checkbox from the KendoReact Grid header while preserving row checkbox selection.