Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DataGrid ReadData not handling pagination properly #5116

Closed
David-Moreira opened this issue Oct 28, 2023 Discussed in #5115 · 0 comments
Closed

DataGrid ReadData not handling pagination properly #5116

David-Moreira opened this issue Oct 28, 2023 Discussed in #5115 · 0 comments
Assignees
Labels
Area: DataGrid Priority: High ⚡ Type: Possible Bug Needs to investigate more to see if it's an actual bug.
Milestone

Comments

@David-Moreira
Copy link
Contributor

Discussed in #5115

Originally posted by mdmontesinos October 28, 2023
DataGrid with ReadData mode does not handle correctly pagination.

I have a PageSize of 1, 2 elements, and I am in page 2, everything's correct:

image

However, when changing to a PageSize of 5, the ReadData event is not triggered so the data source is not updated from the API, even if the DataGrid does change its internal value to 5 and shows that there's no previous page.

image

The last console.log I get is "PageSize: 1, CurrentPage: 2", when the ReadData event should be triggered with "PageSize: 5, CurrentPage: 1".

I'm using Tailwind provider, if it's any help.

Here's the code for it (the data source is just an API with simple pagination mecanism):

<DataGrid TItem="ClinicDto"
          Data="@clinics"
          ReadData="@OnReadData"
          TotalItems="@totalClinics"
          Responsive
          ShowPager
          ShowPageSizes
          PageSizes="new[] { 1, 5, 10, 15 }"
          PagerPosition="DataGridPagerPosition.Bottom">

     <DataGridColumn Field="@nameof(ClinicDto.Name)" Caption="Nombre" Sortable="true" />
     <DataGridColumn Field="@nameof(ClinicDto.Address)" Caption="Dirección" />
     <DataGridColumn Field="@nameof(ClinicDto.PhoneNumber)" Caption="Teléfono" />
     <DataGridColumn Field="@nameof(ClinicDto.Email)" Caption="Correo electrónico" />

 </DataGrid>

@code {
    PagedList<ClinicDto>? clinics;
    int totalClinics;

    private async Task OnReadData(DataGridReadDataEventArgs<ClinicDto> e)
    {
        if (e.CancellationToken.IsCancellationRequested) return;

        Console.WriteLine($"PageSize: {e.PageSize}, CurrentPage: {e.Page}");

        var parameters = new ClinicParameters()
            {
                PageSize = e.PageSize,
                PageNumber = e.Page,
            };

        clinics = await ClinicsHttpRepository.GetClinics(parameters);
        totalClinics = clinics.MetaData.TotalCount;
    }
}
```</div>
@David-Moreira David-Moreira added Type: Possible Bug Needs to investigate more to see if it's an actual bug. Priority: High ⚡ Area: DataGrid labels Oct 28, 2023
@David-Moreira David-Moreira added this to the 1.3 support milestone Oct 28, 2023
@David-Moreira David-Moreira self-assigned this Oct 28, 2023
@stsrki stsrki closed this as completed Nov 9, 2023
@stsrki stsrki added this to Support Aug 3, 2024
@stsrki stsrki moved this to ✔ Done in Support Aug 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: DataGrid Priority: High ⚡ Type: Possible Bug Needs to investigate more to see if it's an actual bug.
Projects
Archived in project
Development

When branches are created from issues, their pull requests are automatically linked.

2 participants