I am trying to access mudradiogroup that is inside the muddatagrid. When i try to select single radiobutton , its select all.
Please check and help me
here is the code and link https://try.mudblazor.com/snippet/QYQIEJmIGpDVaCco
@inject ISnackbar Snackbar
<MudDataGrid Items="@employees" Filterable="false" SortMode="@SortMode.None" Groupable="false">
<Columns>
<PropertyColumn Property="x => x.Name" />
@*<PropertyColumn Property="x => x.Position" />
<PropertyColumn Property="x => x.YearsEmployed" Title="Years Employed" />
<PropertyColumn Property="x => x.Salary" Format="C" />
<PropertyColumn Property="x => x.Salary * x.YearsEmployed" Title="Total Earned" Format="C" />*@
<TemplateColumn CellClass="d-flex justify-end">
<CellTemplate>
<MudStack Row>
@* <MudRating Size="@Size.Small" SelectedValue="@context.Item.Rating" />*@
<MudRadioGroup T="string" @bind-Value="@SelectedOption" SelectedValue="@context.Item.ispresent"
SelectedOptionChanged="OnSelectedOptionChanged">
<MudRadio Option="@("Yes")" Value="@("Yes")" Color="Color.Primary">Yes</MudRadio>
<MudRadio Option="@("No")" Value="@("No")" Color="Color.Secondary">No</MudRadio>
</MudRadioGroup>
@*<MudButton Size="@Size.Small" Variant="@Variant.Filled" Color="@Color.Primary">Hire</MudButton>*@
</MudStack>
</CellTemplate>
</TemplateColumn>
</Columns>
</MudDataGrid>
@code {
public record Employee(string Name, string Position, int YearsEmployed, int Salary, int Rating,string ispresent);
public IEnumerable<Employee> employees;
public string SelectedOption { get; set; }
protected override void OnInitialized()
{
employees = new List<Employee>
{
new Employee("Sam", "CPA", 23, 87_000, 1,"No"),
new Employee("Alicia", "Product Manager", 11, 143_000, 5,"Yes"),
new Employee("Ira", "Developer", 4, 92_000, 3,"No"),
new Employee("John", "IT Director", 17, 229_000, 4,"No"),
};
}
private void OnSelectedOptionChanged(string selectedOption)
{
SelectedOption = selectedOption;
Snackbar.Add(selectedOption);
// call your stuff
}
}
I am trying to access radioubutton from datagrid in the mud blazor component
New contributor
Shrikant Chavan is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.