I am trying to set up a check box in my grid for selection. Here is my sample grid looks like.
<div class="row section-top">
<div class="col">
<SfGrid @ref="GridInstance" DataSource="@_names" AllowSelection="true" AllowPaging="true">
<GridSelectionSettings CheckboxOnly="true" PersistSelection="true"></GridSelectionSettings>
<GridColumns>
<GridColumn Type="ColumnType.CheckBox" Width="50"></GridColumn>
<GridColumn Field="@nameof(Id)" HeaderText="Id" IsPrimaryKey="true"></GridColumn>
<GridColumn Field="@nameof(Name)" HeaderText="Name"></GridColumn>
</GridColumns>
</SfGrid>
</div>
</div>
It does show me checkbox and also select all works. But How Do i bind this to the grid so i can get the selected records/objects?
I tried this on click event but not working.
var selectedItems = this.GridInstance.GetSelectedRecordsAsync();
var selectedItemIds = new List<int>();
selectedItems.GetAwaiter().OnCompleted(() =>
{
selectedItemIds = selectedItems.Result.Select(s => s.Id).ToList();
});
Can anyone help how i can get selected grid rows from Syncfusion Blazor SFGrid?
Aucun commentaire:
Enregistrer un commentaire