Grid Checkbox Column
This article describes the configuration parameters of the Blazor GridCheckboxColumn.
The GridCheckboxColumn provides an additional way for users to select Grid rows. By default, users can select and unselect rows by clicking anywhere on them.
If you need checkboxes to display or edit boolean values, then use a Grid column template instead.
Parameters
The Grid checkbox column has the following exclusive parameters. For other available parameters, see the appearance settings of bound columns.
| Parameter | Type and Default Value | Description |
|---|---|---|
CheckBoxOnlySelection | bool | Determines if row selection occurs only on checkbox clicks. By default, user can select rows by clicking anywhere, except on command buttons. |
SelectAll | bool ( true) | Determines if the column header renders a checkbox to select all rows. Set this to false if the Grid SelectionMode is Single. The SelectAll parameter has no effect when the checkbox column has a HeaderTemplate. |
SelectAllMode | GridSelectAllMode enum ( Current) | Determines if the header cell checkbox selects all rows on the current page, or all rows in the Grid. Current selects the visible rows on the current page. All selects all the data items, including ones that may be currently filtered out. All requires the Grid to be data-bound via its Data parameter, and not OnRead. When using OnRead, the two SelectAllModes behave identically, because the Grid controls only one page of items. |
Title | string | The text in the checkbox column's header. The title renders only when SelectAll is false. |
If the Grid is bound to an
IQueryable, selecting the header checkbox with theAlloption executes a query against all data. For large data sets, this can affect performance.
Header Template
The HeaderTemplate of the Grid checkbox column enables developers to customize the header cell's rendering and checkbox behavior.
On a side note, it is possible to center the checkboxes in the GridCheckboxColumn without using a template.
The example below doesn't take into account sorting, filtering and paging. If the Grid has any data operations enabled, replace GridData in the custom logic below with the data collection, which the Grid is currently showing.
Grid Checkbox Column Header Template