I have the following code in a Razor component:
<SfGrid TValue="DataItem" ID="Grid"
DataSource="@DataList01"
AllowSorting="false"
AllowFiltering="false"
AllowSelection="true"
AllowPaging="false">
<GridSelectionSettings Type="Syncfusion.Blazor.Grids.SelectionType.Single"></GridSelectionSettings>
<GridColumns>
<GridColumn Field="@DataText" HeaderText="Data"></GridColumn>
</GridColumns>
</SfGrid>
When using that code, I can select any row. However, if I add the event handling:
<SfGrid TValue="DataItem" ID="Grid"
DataSource="@DataList01"
AllowSorting="false"
AllowFiltering="false"
AllowSelection="true"
AllowPaging="false">
<GridSelectionSettings Type="Syncfusion.Blazor.Grids.SelectionType.Single"></GridSelectionSettings>
<GridEvents TValue="DataItem" RowSelected="@(row=> SelectedRow = row.Data)" />
<GridColumns>
<GridColumn Field="@DataText" HeaderText="Data"></GridColumn>
</GridColumns>
</SfGrid>
@code {
public DataItem SelectedRow { get; set; }
}
The selection disappears after clicking it and the data is reloaded.
Can you tell me why? What should I change?
Well, the answer is in the invisible details.
The data source of the grid in the code was significant after all:
It is a gRPC-based stream and it turned out that having it stream data caused the grid to be refreshed on every event interaction.
After using a local copy of the data it provided, the selection works normally.