https://docs.telerik.com/blazor-ui/components/grid/paging
Under the section "Bind Page Size to a variable", if you click preview it generates an error.
Peter
Hi Peter,
The error stems from a minor typo in the provided sample code. Thank you for bringing this to our attention.
I've taken immediate action by creating a pull request that incorporates the necessary correction. This modification is currently pending approval and will enter our live documentation soon.
For your convenience, here is the rectified version:
Dynamic page size change
<select @onchange=@ChangePageSize>
@for (int i = 1; i < 4; i++)
{
<option value=@(i*10)>@(i * 10)</option>
}
<option value="all" selected>all</option>
</select>
<TelerikGrid Data="@MyData" Pageable="true" PageSize="@PageSize">
<GridColumns>
<GridColumn Field="ID"></GridColumn>
<GridColumn Field="TheName" Title="Employee Name"></GridColumn>
</GridColumns>
</TelerikGrid>
@code {
public IEnumerable<object> MyData = Enumerable.Range(1, 50).Select(x => new { ID = x, TheName = "name " + x });
protected int PageSize { get; set; } = 1;
protected void ChangePageSize(ChangeEventArgs e)
{
if (e.Value.ToString().ToLowerInvariant() == "all")
{
PageSize = MyData.Count();
}
else
{
PageSize = int.Parse(e.Value.ToString());
}
}
}
Regards,
Hristian Stefanov
Progress Telerik