ui icon indicating copy to clipboard operation
ui copied to clipboard

Using a nested object with Datatable

Open JojokCreator opened this issue 2 years ago • 3 comments

When using a nested object with the data table I get Column with id 'product.title' does not exist.

  {
    accessorKey: "product.title",
    header: "Title",
    cell: ({ row }) => (
      <div className="capitalize">{row.getValue("product.title")}</div>
    ),
  },

Should this work??

JojokCreator avatar Aug 04 '23 08:08 JojokCreator

You may find the information you need in the tanstack documentation for accessorFn, which can be found here.

Example:

accessorKey: 'title', 
accessorFn: (row) => row.product.title, // return the desired value
cell: ({ row }) => (
  <div className="capitalize">{row.getValue("title")}</div>
),

limitless-dev avatar Aug 04 '23 09:08 limitless-dev

Thankyou!

JojokCreator avatar Aug 04 '23 10:08 JojokCreator

Thanks, that worked!

preshpi avatar Apr 21 '24 14:04 preshpi

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.

shadcn avatar Jul 06 '24 23:07 shadcn