I noticed that when I create a DataGrid, all the rows have this "table-row-selectable" class on it which allows users to click each row and highlight it in blue.
I'd rather eliminate this class/functionality, and it seems like there should be some option on the Data Grid somewhere.
AI suggested
- Selectable="false" - but there is not "Selectable" field
- SelectionMode="DataGridSelectionMode.None" - but "None" isn't an option, just single or mutltple.
I have managed to addRowSelectable="@((args) => false) which eliminates the selectable behavior then applied css of "cursor: default !important;" to eliminate the hover but this feels "hacky" and I'd love to hear if someone has a cleaner approach.
Sample Code
Here's a sample of the code I have:
<DataGrid @ref="DG" TItem="Dto" Data="Entities" ReadData="OnDataGridReadAsync" CurrentPage="CurrentPage" TotalItems="TotalCount" ShowPager="true" PageSize="5" RowSelectable="@((args) => false)"> <DataGridColumns><DataGridColumn Field="@nameof(Dto.Prop1)" Caption="@L["Header1"]" Sortable="true"><DisplayTemplate><strong><Span Class="uppercase">@context.Prop1</Span></strong></DisplayTemplate></DataGridColumn><DataGridColumn Field="@nameof(Dto.Prop2)" Caption="@L["Header2"]" Sortable="true"></DataGridColumn></DataGridColumns></DataGrid>