Can we make page index 0 in when PagerInputType.Input is applied and Data source is null or empty in Pagination section of Telerik Grid for Blazor ?

1 Answer 20 Views
AJAX and Web 2.0 Designs, skins, themes Miscellaneous Telerik Trainer
Piyush
Top achievements
Rank 1
Piyush asked on 30 Nov 2023, 01:12 PM

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>(); 
        
}

1 Answer, 1 is accepted

Sort by
1
Accepted
Dimo
Telerik team
answered on 05 Dec 2023, 10:00 AM

Hi Piyush,

We may remove the pager textbox when there are no items in the next release in January 2024. In the meantime, you can use the following KB article to remove the Grid pager conditionally (or parts of it).

In addition, I see that your company has several Telerik licenses, but your account does not. Please ask the license holder at your company to assign you a license, so that your Telerik account is in good standing and you can use technical support.

Regards,
Dimo
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!
Tags
AJAX and Web 2.0 Designs, skins, themes Miscellaneous Telerik Trainer
Asked by
Piyush
Top achievements
Rank 1
Answers by
Dimo
Telerik team
Share this question
or