#React filter null value in column

1 messages · Page 1 of 1 (latest)

past igloo
#

hello

i'm on react-table v8
i am trying to figure out how to filter out (or the opposite) null values in a specifique column.
I switch mode with a button in the header.

what should I pass in header.column.setFilterValue() to do so?

thanks

dusk tree
#

Does your accessor or accessorFn return null value?

I think this might be related, you should convert the value to empty string accessorFn: (row) => row.yourColumnValues ?? '', and filter out empty string instead

Not only this helps me with the sorting behavior (https://github.com/TanStack/table/issues/4289) this also explicitly define your value to only string.

We also had problem with number Filter Type too and decided to convert the number value to string instead.

GitHub

Describe the bug In some cases, when an undefined cell value is present in a column, the sorting toggle for that column doesn't follow the asc-desc-undefined pattern; instead, it may go asc...

past igloo
#

Thanks for the reply.
Even if a transform null to '', how do I filter to only empty string ?
Do I need to replace the filterFn of the columnDef ?