Class GridSelectionSettings
Configures grid selection.
Inherited Members
Namespace: Syncfusion.Blazor.Grids
Assembly: Syncfusion.Blazor.Grids.dll
Syntax
public class GridSelectionSettings : SfOwningComponentBase, IComponent, IHandleEvent, IHandleAfterRender, IDisposable
Constructors
GridSelectionSettings()
Declaration
public GridSelectionSettings()
Properties
AllowDragSelection
Gets or sets whether to enable selection of multiple rows and cells by dragging mouse.
Declaration
[Parameter]
[JsonPropertyName("allowDragSelection")]
public bool AllowDragSelection { get; set; }
Property Value
| Type | Description |
|---|---|
| bool |
|
Remarks
To perform drag selection in blazor grid, set Type as should be Multiple.
CellSelectionMode
The cell selection modes are flow and box. It requires the Mode to be either cell or both.
- FlowDefault. Selects the range of cells between start index and end index that also includes the other cells of the selected rows..
- BoxSelects the range of cells within the start and end column indexes that includes in between cells of rows within the range
Declaration
[Parameter]
public CellSelectionMode CellSelectionMode { get; set; }
Property Value
| Type |
|---|
| CellSelectionMode |
CheckboxMode
Defines options for checkbox selection Mode. They are,.
- DefaultDefault. In this mode, user can select multiple rows by clicking rows one by one.
- ResetOnRowClickIn ResetOnRowClick mode, on clicking a row it will reset previously selected row and also multiple rows can be selected by using CTRL or SHIFT key.
Declaration
[Parameter]
public CheckboxSelectionType CheckboxMode { get; set; }
Property Value
| Type |
|---|
| CheckboxSelectionType |
CheckboxOnly
If CheckboxOnly set to true, then the Grid selection is allowed only through checkbox.
Declaration
[Parameter]
public bool CheckboxOnly { get; set; }
Property Value
| Type |
|---|
| bool |
EnableSimpleMultiRowSelection
If EnableSimpleMultiRowSelection set to true, then the user can able to perform multiple row selection with single clicks.
Declaration
[Parameter]
public bool EnableSimpleMultiRowSelection { get; set; }
Property Value
| Type |
|---|
| bool |
EnableToggle
If EnableToggle set to true, then the user can able to perform toggle for the selected row.
Declaration
[Parameter]
public bool EnableToggle { get; set; }
Property Value
| Type |
|---|
| bool |
IsRowSelectable
Gets or sets a predicate that determines whether an individual row can be selected.
Declaration
[Parameter]
public Func<object, bool>? IsRowSelectable { get; set; }
Property Value
| Type | Description |
|---|---|
| Func<object, bool> | A nullable Func<T, TResult> delegate that receives the row data object as an object and returns true if the row is selectable; otherwise, false. The default value is null, which indicates that all rows are selectable. |
Remarks
Use this property to conditionally enable or disable row selection based on the associated row data.
When this property is null, no selection restrictions are applied and all rows can be selected.
The predicate is evaluated when grid data is processed, and the result is cached for each record. The cache is refreshed whenever row selectability is re-evaluated, such as during filtering, searching, editing, refresh operations, or when a new response is received from a remote data source. Operations such as paging, sorting, grouping, and selection reuse the cached results.
Selection operations generally use the cached result. If a record has not yet been processed and no cached value exists, the predicate may be evaluated once and the result cached for subsequent operations.
Rows for which the predicate returns false are treated as non-selectable.
These rows are ignored by both user interactions and programmatic selection APIs, including
SelectRowAsync and SelectRowsAsync.
When PersistSelection is enabled, only selectable records participate in persisted
selection and Select All operations. If a previously selected record becomes non-selectable
after selectability is re-evaluated, it is automatically removed from the persisted selection.
For remote data sources, row selectability is evaluated only for records contained in the current server response.
This property applies only to row-based selection, including checkbox row selection, and is ignored when the grid is configured for cell selection.
Examples
<SfGrid DataSource="@Orders">
<GridSelectionSettings IsRowSelectable="IsSelectable"
PersistSelection="true" />
</SfGrid>
@code {
private bool IsSelectable(object data)
{
var order = (Order)data;
return order.Status != "Shipped";
}
}
Mode
Specifies the selection mode. Available modes are,.
- RowDefault. Row selection is enabled
- CellCell selection is enabled.
- BothBoth Row and Cell selection is enabled.
Declaration
[Parameter]
public SelectionMode Mode { get; set; }
Property Value
| Type |
|---|
| SelectionMode |
PersistSelection
If PersistSelection set to true, then the Grid selection is persisted on all operations. For persisting selection in the Grid, any one of the column must be enabled as a primary key.
Declaration
[Parameter]
public bool PersistSelection { get; set; }
Property Value
| Type |
|---|
| bool |
Type
Defines options for selection type. They are.
- SingleDefault. Allows selection of only a row or a cell.
- MultipleAllows user to select a multiple rows or cells.
Declaration
[Parameter]
public SelectionType Type { get; set; }
Property Value
| Type |
|---|
| SelectionType |
Methods
OnInitializedAsync()
Invoked during component initialization. Updates the parent grid with the current selection settings and initializes internal state fields.
Declaration
protected override Task OnInitializedAsync()
Returns
| Type |
|---|
| Task |
Overrides
OnParametersSetAsync()
Invoked when component parameters are set or updated. Detects changes in the selection mode and notifies the parent component to handle the update.
Declaration
protected override Task OnParametersSetAsync()
Returns
| Type |
|---|
| Task |