As I set up server-side pagination using PostgreSQL in Appsmith, I realized that I needed to disable client-side pagination and implement my own pagination logic. To do this, I had to create a query to fetch the total number of records in my database and update my query to fetch only 10 records per page. However, I still need to figure out how to implement searching since only a part of my data is available in my Table with server-side pagination.
This article explains how to implement server-side pagination using PostgreSQL in Appsmith. The first step is to disable the client-side pagination feature in the Table settings. Then, we need to create a query that gets the total number of records in the database. This query will help Appsmith to divide the table into the appropriate number of pages. We also need to update our query to fetch only a limited number of records per page using the LIMIT and OFFSET operators.
To re-run the query when the Table widget's state changes, we set the onPageChange and onPageSizeChange properties to run the query again. However, searching through the data using the Table widget's search bar won't be very accurate since only a part of the data is available in the Table. Therefore, the next part of this series will explain how to search through the database rather than the Table widget's records.
The article provides code examples, and readers can find the completed application on Appsmith.