I have sfgrid control in my application.I would like to know how to use radio buttion in sfgrid.
For example:
I have 10 records in grid and I have one column called as "Select".I would like to select any one row from grid
|
<SfGrid @ref="Grid" DataSource="@Employees">
<GridColumns>
<GridColumn HeaderText="Select" TextAlign="TextAlign.Center" Width="50">
<Template>
@{
var employee = (context as EmployeeData);
<div class="image">
<SfRadioButton Name="selection" ValueChange="@((args)=>OnChange(args,employee))" TChecked="bool"></SfRadioButton>
</div>
}
</Template>
</GridColumn>
<GridColumn Field=@nameof(EmployeeData.EmployeeID) HeaderText="Employee ID" TextAlign="TextAlign.Right" Width="120"></GridColumn>
<GridColumn Field=@nameof(EmployeeData.HireDate) HeaderText="Hire Date" Format="d" TextAlign="TextAlign.Right" Width="150"></GridColumn>
</GridColumns>
</SfGrid>
@code{
SfGrid<EmployeeData> Grid { get; set; }
public List<EmployeeData> Employees { get; set; }
public async Task OnChange(ChangeArgs<bool> Args, EmployeeData val)
{
//to find the row index
var rowIndex = Grid.CurrentViewData.ToList().IndexOf(val);
//select the record using index and SelectRow method
await Grid.SelectRow((double)rowIndex,false);
}
|