ui
ui copied to clipboard
Data Table - Filter by number not working
I am using the data table with filters on columns. The filters for string valued columns work great, but a filter on a number column does not.
What is the best way to get around this?
Thx
Hey did you find any solution?
No, i did not... if i dont find one soon, I will be switching to a different UI solution
Hey I got a solution, just make your data type to string using accessorFn in columns.
But there is catch, now that I have changed my data to string if i search by number 1 then I will get all the values from that column which has 1 in it So, I think this could be temporary solution as I did not find any solution on filtering integer data.
You can learn some more here: https://github.com/TanStack/table/issues/4210
Hope this helps
Here is what I did:
filterFn: (row, columnId, filterValue: string) => {
const search = filterValue.toLowerCase();
let value = row.getValue(columnId) as string;
if (typeof value === "number") value = String(value);
return value?.toLowerCase().includes(search);
},
for column def
This issue has been automatically closed because it received no activity for a while. If you think it was closed by accident, please leave a comment. Thank you.