Which approach is optimal for implementing server-side pagination with MatTableDataSource?
0 reputation · 12 Jan 2020, 12:44 UTC
Angular Material's MatTableDataSource provides seamless client-side integration for MatPaginator and MatSort. However, when dealing with large datasets that exceed memory limits, server-side processing is required to maintain performance.
The primary challenge lies in the transition from the built-in client-side logic to a custom data stream. While the MatTableDataSource is designed for local arrays, server-side implementations typically require a custom DataSource class to intercept pagination and sorting events and trigger API requests.
Given the declarative nature of matColumnDef and the event-driven behavior of the paginator, there is uncertainty regarding the most maintainable way to synchronize the table's state with an external backend without duplicating sorting logic.
- Does overriding the
connect()method in a customDataSourceprovide sufficient control for complex server-side filtering? - What is the recommended pattern for updating the
MatTableDataSourcewhen the total element count changes on the server?