Super Sale Limited Time 50% OFF for All-Access Plans
Save 50% Now

Load multiple pages data once in the datatable from remote data source


Background: Using Metronic Tailwind version with nextjs.

Question:
How to load all data once spanning multiple pages in the datatable from the remote data source and show it paginated.

Currently if i return all data which is more than the page size it displays all records on the first and only page, instead of paginating it on multiple pages.


Text formatting options
Submit
Click any option to insert into your comment. Select text first to wrap it.
  • **text** to make things bold
  • *text* to emphasize
  • ### Heading to make headings
  • [link text](url) for links
  • ![alt text](image-url) to paste in an image
  • - item to make a list
  • 1. item to make an ordered list
  • > quote to quote somebody
  • `code` for single line of code
  • ```js ... ``` for JS code block
  • ```html ... ``` for HTML code block
  • ```scss ... ``` for SCSS code block
  • ```php ... ``` for PHP code block
  • --- for a horizontal rule
  • happy  :)
  • shocked  :|
  • sad  :(

Replies (2)


@Drift Boss

When using Metronic with Next.js and Tailwind, if your data table is not paginating properly when fetching all data from a remote source, you may need client-side pagination. Implementing Client-Side Pagination
Since your API returns all data at once, you need to paginate manually in the UI instead of relying on the UI.



Hi Qamer Farooq

The KTDataTable is designed with two primary pagination modes:
- Server-side pagination: Where the API returns only one page of data per request
- Local pagination: Where all data is loaded and paginated client-side

Currently when you return all your data from the API, it's displaying everything on a single page because the pagination logic isn't being applied properly to your remote data.

You need to use a custom mapResponse handler that processes all your data at once but still supports pagination. Here's how to implement this:

https://gist.github.com/faizalmy/3bca5b0cf9877d0127fd832d32b70d62


Text formatting options
Submit
Click any option to insert into your comment. Select text first to wrap it.
  • **text** to make things bold
  • *text* to emphasize
  • ### Heading to make headings
  • [link text](url) for links
  • ![alt text](image-url) to paste in an image
  • - item to make a list
  • 1. item to make an ordered list
  • > quote to quote somebody
  • `code` for single line of code
  • ```js ... ``` for JS code block
  • ```html ... ``` for HTML code block
  • ```scss ... ``` for SCSS code block
  • ```php ... ``` for PHP code block
  • --- for a horizontal rule
  • happy  :)
  • shocked  :|
  • sad  :(
Text formatting options
Submit
Click any option to insert into your comment. Select text first to wrap it.
  • **text** to make things bold
  • *text* to emphasize
  • ### Heading to make headings
  • [link text](url) for links
  • ![alt text](image-url) to paste in an image
  • - item to make a list
  • 1. item to make an ordered list
  • > quote to quote somebody
  • `code` for single line of code
  • ```js ... ``` for JS code block
  • ```html ... ``` for HTML code block
  • ```scss ... ``` for SCSS code block
  • ```php ... ``` for PHP code block
  • --- for a horizontal rule
  • happy  :)
  • shocked  :|
  • sad  :(