Completed
Last Updated: 03 Jun 2025 13:44 by ADMIN
Release 3.4.0
Sylvain
Created on: 05 May 2022 11:23
Category: Grid
Type: Bug Report
1
Selecting null PageSize throws when the Grid has no data

If the Grid has no data, selecting null PageSize throws:

Error: System.ArgumentException: Page Size cannot be less than one (Parameter 'PageSize') 

---

ADMIN EDIT

---

A possible workaround for the time being will be to use some conditional CSS to disable the PageSize dropdown while there is no data in the Grid: https://blazorrepl.telerik.com/QcOpkTlb38EDFboT34.

2 comments
ADMIN
Dimo
Posted on: 03 Jun 2025 13:44

Hi Maxime,

The fix here addressed an exception that occurred even before loading the data.

In your case, you can check and reset the PageSize when loading the Data in an empty Grid. The real problem is that PageSize "All" is currently a bit of a hack in our source code, because PageSize is an int, while "All" corresponds to null in the PageSizes collection. We have a feature request to allow initial Grid PageSize All and I voted on your behalf.

    async Task LoadData()
    {
        GridData = Enumerable.Range(1, 30).Select(x => new Product
        {
            Id = x,
            Name = "Product name " + x,
            Price = (decimal)(x * 3.14),
            Released = DateTime.Now.AddMonths(-x).Date,
            Discontinued = x % 5 == 0
        }).ToList();

        if (PageSize == 0)
        {
            PageSize = GridData.Count;
        }
    }

 

Regards,
Dimo
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

Maxime
Posted on: 30 May 2025 14:44

Hey, I know this ticket is old, but as far as I understand, the fix was implemented in version 3.4.0. However, when I use the same REPL code above (just updating the Telerik Blazor version to the latest one), the bug still occurs (If you choose "all" and then load the data, it crashes)

Am I wrong or missing something?