As show in the screenshot the output is "1 of 0" in the pagination section of the telerik grid when Data is null or empty meaning no records available.
I tried to make it 0 while its running but couldn't as the input field is allowing value > 0 only, I guess. Is there an easy or quick solution for this?
Or may be I am doing something wrong. below is my code.
@* Set initial page index, and keep it updated with the grid state to prevent it from resetting the grid page index on re-renders *@
<TelerikGrid Data="@MyData" Pageable="true" @bind-PageSize="@PageSize" Height="300px"
FilterMode="Telerik.Blazor.GridFilterMode.FilterRow" @bind-Page="@PageIndex">
<GridSettings>
<GridPagerSettings InputType="PagerInputType.Input"
PageSizes="@PageSizes"
ButtonCount="10"
Adaptive="true"
Position="PagerPosition.Bottom">
</GridPagerSettings>
</GridSettings>
<GridColumns>
<GridColumn Field="ID"></GridColumn>
<GridColumn Field="TheName" Title="Employee Name"></GridColumn>
</GridColumns>
</TelerikGrid>
@code {
protected List<int?> PageSizes { get; set; } = null; //new List<int?> { null, 15, 30, 50 };
int PageIndex { get; set; } = 0;
int PageSize { get; set; } = 10;
// I have tried it with Pagechanged event as well instead of 2-way data binding but it didn't worked.
async Task PageChangedHandler(int currPage)
{
if(MyData == null || !MyData.Any())
PageIndex = 0;
else
await Task.Run(() => PageIndex = currPage);
// when using one-way binding for the Page parametr, make sure to update it in the PageChanged event
}
public IEnumerable<object> MyData = Enumerable.Empty<object>();
}