DataTables Lazy loading example question

UI Components for React
Post Reply
mrzurkon
Posts: 4
Joined: 02 Jul 2022, 01:06

11 Jul 2022, 08:59

Hi,

I must admit I am fairly new to React so this may be a silly question.

But I'm looking at the DataTables lazy loading example https://www.primefaces.org/primereact/datatable/lazy/ and I am trying to understand why it passes the entire 'LazyEvent' to as query parameters to
https://www.primefaces.org/data/customers ?

For example:

Code: Select all

lazyEvent=
{
   "first":30,
   "rows":10,
   "sortField":null,
   "sortOrder":null,
   "multiSortMeta":[
      
   ],
   "filters":{
      "name":{
         "value":"",
         "matchMode":"contains"
      },
      "country.name":{
         "value":"",
         "matchMode":"contains"
      },
      "company":{
         "value":"",
         "matchMode":"contains"
      },
      "representative.name":{
         "value":"",
         "matchMode":"contains"
      }
   },
   "page":3,
   "pageCount":20
}
I understand we might wish pass to the backend which page of data we need next, but why are the filters and sort information passed as well?

many thanks.

Melloware
Posts: 3247
Joined: 22 Apr 2013, 15:48

11 Jul 2022, 14:03

you are referring to this line "customerService.getCustomers({ lazyEvent: JSON.stringify(lazyParams) })" right? You don't have to do that the lazyParams can be used to call your REST Services however you want. That example just shows it passing the whole thing but there is nothing stopping you from having a REST service that has just two params like /rest/myservice?page=0&first=10&last=20 etc
PrimeFaces Developer | PrimeFaces Extensions Developer
GitHub Profile: https://github.com/melloware
PrimeFaces Elite 11.0.3 / PF Extensions 11.0.3
PrimeReact 8.0.0

mrzurkon
Posts: 4
Joined: 02 Jul 2022, 01:06

12 Jul 2022, 02:38

Thank you.

Yeah I was just trying to understand the reasoning behind it. After some more thought I guess it makes sense that you 'should' filter on the backend for lazy loading

Post Reply

Return to “PrimeReact”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 2 guests