<EjsGrid @ref="GridInstance" DataSource="@Orders" AllowPaging="true">
<Syncfusion.EJ2.Blazor.Grids.GridSelectionSettings CheckboxOnly="true"></Syncfusion.EJ2.Blazor.Grids.GridSelectionSettings>
<GridPageSettings PageSize="5"></GridPageSettings>
<GridColumns>
<GridColumn>
<Template>
@{
var PrimaryVal = (context as Order);
<EjsRadioButton Name="RadioBtn" @ref="Radio" Value="@PrimaryVal.CustomerID" ValueChange="ValueChange"></EjsRadioButton> @*Set Value property based on primary Key column(CustomerID) value.*@
}
</Template>
</GridColumn>
<GridColumn Field=@nameof(Order.CustomerID) HeaderText="Customer Name" IsPrimaryKey="true" Width="150"></GridColumn> @*Set primary Key for an unique value column and assign that column value as value for radio button’s Value property also*@
</GridColumns>
</EjsGrid>
@code{
EjsRadioButton Radio;
EjsGrid<Order> GridInstance;
...
public async void ValueChange(ChangeArgs args)
{
var index = await GridInstance.GetRowIndexByPrimaryKey(args.Value); //Fetch the row index based on the unique Value of RadioButton
GridInstance.SelectRow(index); //Select the corresponding Grid row.
}
}
|