PrimeReact DataTable alternative server-side pagination

UI Components for React
Post Reply
fabio.costa
Posts: 2
Joined: 26 May 2021, 20:27

26 May 2021, 20:52

Hi there! I have this very large data to fetch in my app and for that i have an API that provides me the number of pages i`ll get deppending on the number of rows i whant to show per page. So i can fetch only de first page, for example, and then make new requests on each page number i click!

I`m aware of the Lazyloading provided by this component but my problem is to fetch all the data, store it at state and then, filter it before render.

Is there a way to make the datatable paginator shows the number of pages links my API returns?

Thank you vary much, best regards!

Fábio

fabio.costa
Posts: 2
Joined: 26 May 2021, 20:27

07 Jun 2021, 15:42

Well, i`ve done it myself with one "workaround" that might be usefull for others too:
Since my API returns how many pages exists deppendind on rows number per page sent to request, using the Lazy attribute of DataTable i`ve calculated the totalRecords by multiplying rows sent and pages number returned.

I uderstand that the "rows" and "totalRecords" attributes at "Lazy" mode can return the number os page links that paginator needs to deal with total records to show. My totalRecords does not allways returns the exact total records number but since its only goal is to return paginator page links, it works perfectly!

Post Reply

Return to “PrimeReact”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 5 guests