Completed
Last Updated: 18 Aug 2023 15:28 by ADMIN
Peter
Created on: 17 Aug 2023 17:56
Category: UI for Blazor
Type: Bug Report
0
Blazor Documentation bug

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

1 comment
ADMIN
Hristian Stefanov
Posted on: 18 Aug 2023 15:28

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

Stay tuned by visiting our public roadmap and feedback portal pages! Or perhaps, if you are new to our Telerik family, check out our getting started resources!