Deselect row in Blazor datagrid

Hi,

Is it possible to deselect a row in a datagrid? I have a multilevel grid where I would like to "keep" the leaf grids open. However, if I select a row on the first leaf and then expand another parent and select a row in the second leaf, the row in the first leaf stays selected. I would like it to deselect (it is used in a master/detail form).

I know I can use ExpandMode="DataGridExpandMode.Single" and that will rerender the leafs on the parent, but that is not ideal as I want the expanded hierarchy to be visible to the user.

Thanks!

Here are two an examples with latest Radzen.Blazor:

@enchev Hello!

Are either of these two methods working with the latest data grid? I've tried everything and can see in the debugger that the row I want is selected, but the selected row itself does not become selected/highlighted on the grid itself.

Thank you,
SloSuenos

Hey @SloSuenos,

Do you want to select first row initially? You can check how this is done in our Master/Detail template:


1 Like

@enchev thank you.

For anyone else who gets stuck on this in the future. The difference was how the TItem was defined. I was doing:

Invoke getDBbyID param ID = 39
Set selectedRow to result
grid.SelectRow(selectedRow)

Seems like that should work, and indeed it does except that while the row is selected in the background and the RowSelect event is fired, the grid doesn't show the row as selected. As you demonstrate, what works completely is:

set selectedRow to grid.View.Where(x => x.ID == 39).FirstOrDefault()
grid.SelectRow(selectedRow)

Thanks again for the help,
Slosuenos