Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

111
Views
Adding checkboxes column for each row in table

Hello how can I add a new column with checkboxes for each row on the left side of my id column.

export default function Display() {
  const { menus } = JsonData;

  const data = useMemo(
    () => [
      {
        Header: "Id",
        // accessor: "id"
        accessor: (row) => row.id
      },
      {
        Header: "Title",
        accessor: (row) => ({ title: row.title, id: row.id }),        
        Cell: ({ value }) => (
          <Link to={{ pathname: `/menu/${value.id}` }}>{value.title}</Link>
        )
      }
    ],
    []
  );

   return (
    <Table
      data={menus}
      columns={data}
      withCellBorder
      withRowBorder
      withSorting
      withPagination
    />
  );
}

Here is my codeSandbox

about 4 years ago · Santiago Trujillo
2 answers
Answer question

0

Just add a new entry into the array:

export default function Display() {
  const { menus } = JsonData;

  const data = useMemo(
    () => [
      {
        Header: "Ceckbox",
        // accessor: "id"
        accessor: (row) => row.id,
        Cell: ({ value }) => (
          <input type='checkbox' />
        )
      },
      {
        Header: "Id",
        // accessor: "id"
        accessor: (row) => row.id
      },
      {
        Header: "Title",
        accessor: (row) => ({ title: row.title, id: row.id }),        
        Cell: ({ value }) => (
          <Link to={{ pathname: `/menu/${value.id}` }}>{value.title}</Link>
        )
      }
    ],
    []
  );

   return (
    <Table
      data={menus}
      columns={data}
      withCellBorder
      withRowBorder
      withSorting
      withPagination
    />
  );
}
about 4 years ago · Santiago Trujillo Report

0

You can add new column to your data :

const data = useMemo(
    () => [
      {
        id: "check",
        accessor: (row) => row.title,
        Cell: ({ value }) => <input type="checkbox" value={value} />
      },
      {
        Header: "Id",
        // accessor: "id"
        accessor: (row) => row.id
      },
      {
        Header: "Title",
        // accessor: "title"
        accessor: (row) => ({ title: row.title, id: row.id }),
        // accessor: (row) => (
        //   <Link to={{ pathname: `/menu/${row.id}` }}>{row.title}</Link>
        // )
        // Link the content of my cell. NOT WORKING
        //Cell: ({ row }) => (
        //<Link to={{ pathname: `/menu/${row.id}` }}>{row.title}</Link>
        //)
        Cell: ({ value }) => (
          <Link to={{ pathname: `/menu/${value.id}` }}>{value.title}</Link>
        )
      }
    ],
    []
  );

Edit filters (forked)

about 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!