PageSizeOptions does not work with LoadData in RadzenDataGrid

PageSizeOptions does not work with LoadData in RadzenDataGrid. The value selected from PageSizeOptions gets overriden by the value mentioned in PageSize property. For example, if the PageSize is 4 and from the PageSizeOptions dropdown I select 10, it will still load 4 records instead of 10. Is there any fix for this?

<RadzenExample Name="DataGridLoadData" Heading="false" Documentation="false">
    <RadzenButton Text="Reset" Click="@Reset" Style="margin-bottom: 20px;" />
    <RadzenDataGrid @ref="grid" Count="@count" Data="@employees" 
        LoadData="@LoadData" AllowSorting="true" AllowFiltering="true" AllowPaging="true" 
        PageSize="4" TItem="Employee" ColumnWidth="200px"
            <RadzenDataGridColumn TItem="Employee" Property="EmployeeID" Filterable="false" Title="ID" Frozen="true" Width="50px" TextAlign="TextAlign.Center" />
            <RadzenDataGridColumn TItem="Employee" Title="Photo" Sortable="false" Filterable="false" Width="200px" >
                <Template Context="data">
                    <RadzenImage Path="@data.Photo" style="width: 40px; height: 40px; border-radius: 8px;" />
            <RadzenDataGridColumn TItem="Employee" Property="FirstName" Title="First Name" />
            <RadzenDataGridColumn TItem="Employee" Property="LastName" Title="Last Name" Width="150px"/>
            <RadzenDataGridColumn TItem="Employee" Property="Title" Title="Title" />
            <RadzenDataGridColumn TItem="Employee" Property="TitleOfCourtesy" Title="Title Of Courtesy" />
            <RadzenDataGridColumn TItem="Employee" Property="BirthDate" Title="Birth Date" FormatString="{0:d}" />
            <RadzenDataGridColumn TItem="Employee" Property="HireDate" Title="Hire Date" FormatString="{0:d}" />
            <RadzenDataGridColumn TItem="Employee" Property="Address" Title="Address" />
            <RadzenDataGridColumn TItem="Employee" Property="City" Title="City" />
            <RadzenDataGridColumn TItem="Employee" Property="Region" Title="Region" />
            <RadzenDataGridColumn TItem="Employee" Property="PostalCode" Title="Postal Code" />
            <RadzenDataGridColumn TItem="Employee" Property="Country" Title="Country" />
            <RadzenDataGridColumn TItem="Employee" Property="HomePhone" Title="Home Phone" />
            <RadzenDataGridColumn TItem="Employee" Property="Extension" Title="Extension" />
            <RadzenDataGridColumn TItem="Employee" Property="Notes" Title="Notes" />

    RadzenDataGrid<Employee> grid;
    int count;
    IEnumerable<Employee> employees;
    public IEnumerable<int> PagingOptions { get; set; } = new int[] { 10, 20, 30 };

    async Task Reset()
        await grid.FirstPage(true);

    void LoadData(LoadDataArgs args)
        // This demo is using
        var query = dbContext.Employees.AsQueryable();

        if (!string.IsNullOrEmpty(args.Filter))
            // Filter via the Where method
            query = query.Where(args.Filter);

        if (!string.IsNullOrEmpty(args.OrderBy))
            // Sort via the OrderBy method
            query = query.OrderBy(args.OrderBy);

        // Perform paginv via Skip and Take.
        employees = query.Skip(args.Skip.Value).Take(args.Top.Value).ToList();

        // Important!!! Make sure the Count property of RadzenDataGrid is set.
        count = dbContext.Employees.Count();

1 Like

Maybe you should include this value in the list of page size options.

1 Like

@enchev I tried adding the value 4 to the list of page size options, but still its not working. Even when I select the page size 10, 20 or 30, it shows 4 records in each page.

Hey @ShivDarshanSingh,

LoadData examples can be found here:

Stop cross posting your questions in our forum or we will discontinue your account.

1 Like