React filter null value in column
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?
thanks3 Replies
harsh-harlequin•3y ago
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
Sorting state behavior is changed if column data includes undefined...
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...
like-goldOP•3y ago
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 ?
harsh-harlequin•3y ago
That's actually a good question, i have some thought about it too. Maybe you could pass your custom
filterFn
or use filterFn: equals