Add line breaks / newline for cell entries being of type array #5287
-
|
Some of my cell data may either be Is there to render the data as such: A likewise: 1 I added a code sandbox link of fresh next/shadcn setup:
In that example, there can be multiple email fields and I want to show them line-by-line. How can I intercept that in tanstack table v8? In other words, I need a |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
|
Alright, after digging a bit, I realized I can modify the cell property: {
accessorKey: "email",
header: "Email",
},
{
accessorKey: "email",
header: "Email",
+ cell: ({ getValue }) => (
+ <span>
+ {Array.isArray(getValue()) ? (
+ <ul>
+ {(getValue() as string[]).map((item: string, index: number) => (
+ <li key={index}>• {item}</li>
+ ))}
+ </ul>
+ ) : (
+ (getValue() as React.ReactNode)
+ )}
+ </span>
+ ),
},The changes are in the link from top. |
Beta Was this translation helpful? Give feedback.


Alright, after digging a bit, I realized I can modify the cell property:
{ accessorKey: "email", header: "Email", }, { accessorKey: "email", header: "Email", + cell: ({ getValue }) => ( + <span> + {Array.isArray(getValue()) ? ( + <ul> + {(getValue() as string[]).map((item: string, index: number) => ( + <li key={index}>• {item}</li> + ))} + </ul> + ) : ( + (getValue() as React.ReactNode) + )} + </span> + ), },The changes are in the link from top.