If I have a button in a Mudblazor datagrid with a Mudbutton in a column. I can run a method on that button such as onclick="Test". But how do I pass a parameter into the method showing which row the button was pressed? I would assume it would be something like this:
The onclick is not working. Can someone point me in the right direction, please?
Thanks,
Greg
C#:
<MudDataGrid Items="@employees" Filterable="false" SortMode="@SortMode.None" Groupable="false">
<Columns>
<PropertyColumn Property="x => x.Name" />
<TemplateColumn CellClass="d-flex justify-end">
<CellTemplate>
<MudStack Row>
<MudButton @onclick="@(x => Test(@x.Name))" Size="@Size.Small" Variant="@Variant.Filled" Color="@Color.Primary">Hire</MudButton>
</MudStack>
</CellTemplate>
</TemplateColumn>
</Columns>
</MudDataGrid>
@code {
private void Test(string stuff)
{
Console.WriteLine(stuff); //SoundIds.Add(await Howl.Play(file));
}
}
The onclick is not working. Can someone point me in the right direction, please?
Thanks,
Greg