I can add the button, but I need to be able to identify the row that the button was on in the @onclick event so that I can pop-up a form with information specific to that row.
If you want to use a Template in a data column, you need to use a lambda expression in the OnClick handler so you can pass extra data from the context, something like this:
<TelerikGrid Data="@MyData" Height="400px"
Pageable="true" Sortable="true" Groupable="true"
FilterMode="Telerik.Blazor.GridFilterMode.FilterRow"
Resizable="true" Reorderable="true">
<GridColumns>
<GridColumn Field="@(nameof(SampleData.Id))" Width="120px">
<Template>
@{
SampleData currItem = context as SampleData;
<TelerikButton OnClick="@( _ => HandleClick(currItem.Id) )">click me</TelerikButton>
<button @onclick="@( _ => HandleClick(currItem.Id) )">I do the same</button>
}
</Template>
</GridColumn>
<GridColumn Field="@(nameof(SampleData.Name))" Title="Employee Name" Groupable="false" />
</GridColumns>
</TelerikGrid>
@code {
voidHandleClick(int theId)
{
Console.WriteLine(theId);
}
public IEnumerable<SampleData> MyData = Enumerable.Range(1, 30).Select(x => new SampleData
{
Id = x,
Name = "name " + x
});
publicclassSampleData
{
publicint Id { get; set; }
publicstring Name { get; set; }
}
}