Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

113
Visualizações
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 Respostas
Responde à pergunta

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 Relatório

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda