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

Server side pagination #84

Open
diasandreotti opened this issue Sep 9, 2020 · 6 comments
Open

Server side pagination #84

diasandreotti opened this issue Sep 9, 2020 · 6 comments

Comments

@diasandreotti
Copy link

I'm trying the same problem reported in #34. And I have the updated version of the angular

@sbalmos
Copy link

sbalmos commented Dec 21, 2021

Likewise same issue here. The exporter does not seem to want to use a returned Promise, Observable, BehaviorSubject, anything that would have an async delay such as server-side delay. I have attached a minimal example here. The private getData() returning a Promise is meant to simulate the server-side paging with a 250ms response delay. The table display and paging display the 4 pages of 5 entries each fine. Exporting will only yield a CSV with the first page of 5 entries, however.

app.component.zip

@ahmadabulaban
Copy link

I'm facing same issue, i think the exporter doesn't wait for any delay caused by subscription of server side hits

@sbalmos
Copy link

sbalmos commented Feb 8, 2022

I'm slowly peeling back the onion on this one. It's multi-faceted. At the root (so far), cdk-table-exporter attempts to collect all pages of a paged datasource before exporting by subscribing to the data source's page change Observable. In mat-table-exporter, this boils down to the MatPaginator's page event. But in the typical server-side paging scenario, this page event signals the start of a page change, not the completion of it. Almost all server-side paging tutorials show how to subscribe to this page event to catch a page change request and request the appropriate page from the backend. But, like I mentioned, this is the start of a page change.

I am currently investigating possibly replacing cdk-table-exporter's subscribing to the page change observable, and to have it subscribe to the underlying Data Source's connect() Subject. This Subject is what ultimately sends data to the Table to be rendered, and thus would be a better indicator of when the data is actually received from the backend. But MatTableDataSource has its own potential issues there related to how it tries to handle paging itself. It basically causes multiple "new data" events to be emitted. Too long to explain here, but it also explains why most server-side paging examples also require you to reset the MatPaginator's length, pageIndex, and pageSize properties again in a setTimeout() /after/ you have set the MatTableDataSource's data property. It's the MatTableDataSource trying to be smarter than you.

I'll let everyone know if I figure out anything useful.

@rodriggit
Copy link

I'm having this issue too. It would be nice to have a feature to export single page even when the paginator is present

@yashagldit
Copy link

@sbalmos Did you or anyone figure it out?

@sbalmos
Copy link

sbalmos commented Apr 3, 2023

Not really. Some attempts sort of worked but ultimately still broke. I have since moved on to another position and no longer maintain the app where this functionality was relevant.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants