DxDataGrid<T>.RowClick Event
Fires when a user clicks a grid’s data row.
Namespace: DevExpress.Blazor
Assembly: DevExpress.Blazor.v22.1.dll
Declaration
[Parameter]
public Action<DataGridRowClickEventArgs<T>> RowClick { get; set; }
Event Data
The RowClick event's data class is DataGridRowClickEventArgs<T>. The following properties provide information specific to this event:
Property | Description |
---|---|
DataItem | Specifies a data item the clicked row is bound to. |
Handled | Specifies whether the clicked row selection should be canceled. |
MouseEventArgs | The Blazor’s built-in MouseEventArgs event arguments. |
Remarks
Important
The Data Grid was moved to maintenance support mode. No new features/capabilities will be added to this component. We recommend that you migrate to the Grid component.
The examples below demonstrate how you can handle this event.
Double-Click Handler
You can use the RowClick
event to handle a double-click on a row. The handler should use the MouseEventArgs.Detail property.
<DxDataGrid @ref="@grid"
RowClick="@OnRowClick">
...
</DxDataGrid>
@code {
void OnRowClick(DataGridRowClickEventArgs<SampleModel> args) {
if(args.MouseEventArgs.Detail == 2) {
// Double-click handler
}
}
}
Clear Row Selection
In single selection mode, a user can do any of the following to clear row selection:
- Click the selected row with the
Ctrl
key pressed. - Click (and select) another row.
You can use the OnRowClick
handler to override the default behavior. For example, to cancel row selection, users should not press Ctrl
when they click the row:
<DxDataGrid @ref="@grid"
Data="@Vacancies"
RowClick="@OnRowClick">
...
</DxDataGrid>
@code {
DxDataGrid<Vacancy> grid;
IEnumerable<Vacancy> Vacancies;
...
void OnRowClick(DataGridRowClickEventArgs<Vacancy> args) {
if (grid.IsDataRowSelected(args.DataItem) && !args.MouseEventArgs.CtrlKey) {
grid.SetDataRowSelected(args.DataItem, false);
args.Handled = true;
}
}
}