2

I have a problem with DataTable and lazy loading.

When I activate the lazy loading paramater (which i can't remove because the request from the api is too big) the filtering and sorting does not work when the lazy loading is activated. I understand why it works like that, but I really have no idea how to fix it.

If you have any solutions I take it beacause I'm really stuck here :)

link to codesandbox -> https://codesandbox.io/s/datatable-t92wk

I made some modifications with the base exemple in primereact like adding lazy loading, removing paggination and replace it by virtual scrolling. I also made a modification with the filtering but I think that what I did is not really correct, but it works in that case : it stops the lazy variable and therefore I can use lazy loading.

What I would love to do is to sort already loaded data in the table :)

Thank you

1 Answer 1

0

Had the same issue. Apparently you can't use filtering with lazy loading mode (link). Makes sense really.

For sorting, you could pass an onSort function and everytime a sort event happens (i.e: user clicks on the column header), you can send back a DB request.

const onSort = (e) => {
 // use e.sortField and e.sortOrder to send a DB request,
}

<DataTable onSort={onSort} ... // rest of the stuff />
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.