DEV Community

Adele Beitvashahi
Adele Beitvashahi

Posted on

How to use Filters in PrimeReact DataTables

I wrote a very long post then decided an image is worth a thousand words, so there you go.

Code diagram

Although the images uploaded to dev.to get downscaled so maybe this one is only worth 250 words.

The aim of this post was to reduce headaches induced by things unsaid in the official docs. There was a lack of resources online for using filters with MultiSelect and Dropdown components correctly with a more-than-basic data structure setup. So I'm using this post as a resource for future me and anyone else that might find this useful

If you look at the top left of that image there is a string[] that holds fruit names, that's because you can also use string[] instead of Object[] for the filter item list. I didn't expand on it because the official docs do a good enough job doing it.

I tried to cover things the docs failed to cover.

Here's a working demo where you can play around and get a better understanding of it all. I tried to cover as many different situations as possible.

Top comments (0)