SfGrid RowSelection event handling reloads data

318 views Asked by At

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?

2

There are 2 answers

0
Nestor On BEST ANSWER

Well, the answer is in the invisible details.

The data source of the grid in the code was significant after all:

DataSource="@DataList01"

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.

0
user12702211 On

Can you please share the below information regarding the issue you are facing. Because we are not able to reproduce the reported issue at our end while preparing a sample using your code example and latest version Syncfusion.Blazor Nuget package 18.4.0.47.

Sample: https://www.syncfusion.com/downloads/support/directtrac/general/ze/DataGrid-2097295582

Share the following details, If you are still facing the reported issue

  1. Share your Syncfusion.Blazor Nuget package version details.
  2. Share the video demonstration of the issue.
  3. Try to reproduce the reported issue in the provided sample.