How to add unit text to the end of a cell that is a number, while not having that text affect filter
Lets say I have a table with fields name age and weight. I would like to add years and lbs to the end of the age and weight fields respectfully, but I don't want the text to affect the sort and filter functionality I have in react tables. So both sort and filter should essentially only be looking at the numbers not the appended text.
12 Replies
deep-jade•3y ago
I think you can just set cell on the column config.
like-goldOP•3y ago
I did that for the name field, but when I did that It seemed that I lost the sort functionality
I am trying now
It worked! thank you so much!!!!!!!
One of my fileds is crashing the code tho
#### In the below code the object with the Name header crashes the code unless I remove the accessor field.
I find this weird because without it I cannot get the sort functionality. Event weirder is that it works fine for all the other objects. Any ideas?
Scroll down for more info
And actually it seems even this breaks my code, but my accessor label is correct:
like-goldOP•3y ago
this is the error I get in both cases

like-goldOP•3y ago
In order to get the code to not crash I must do this:
In this case sort feature doesen't work tho
multiple-amethyst•3y ago
shouldn't this be like this?
Similar case using column helper in docs (Basic react example)
and without columnHelper (filters example for React)
and about the unit I think you can do something like this
like-goldOP•3y ago
Thank you so much for taking the time to help me
Unfortunately the solution crashes my code with a renderer error
Also I have updated my working code since I asked this .
multiple-amethyst•3y ago
try adding id to the column
or try removing
.original
like-goldOP•3y ago
Unfortunately that didn't work either. I really really appreciate you taking the time to try and help me with this I am totally lost on this one. Which is weird because this seems like a simple thing
multiple-amethyst•3y ago
maybe try recreating the table in sandbox to isolate the problem
Is it still the same problem?
like-goldOP•3y ago
Ya code crashes whenever I add an accessor to the object with the Header Name
multiple-amethyst•3y ago
it might be due to the "name" being keyword, but not sure
or rather property of some objects
like-goldOP•3y ago
Ok I will try that
which solution should I try with this new key?
Unfortunately this also breaks
It breaks if I remove original as well