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

143
Visualizações
initialization/default of checkbox checked value antd table using local storage react js

In this code, I have created local storage 'selection' for storing what is checked.

when I reload the page, what was selected before should already show a checked

I am not aware if there is a properly like that for antd table please help app.js file

     const { filteredData, loading } = useTableSearch({
    searchVal,
    retrieve: fetchUsers
  });
  function onChange2(pageNumber) {
    console.log("Page: ", pageNumber);
  }
      const rowSelection = {
        onChange: (selectedRowKeys, selectedRows) => {
          localStorage.setItem("selection", JSON.stringify(selectedRows));
          var storage = localStorage.getItem("selection");
          console.log(storage);
          // console.log(
          //   `selectedRowKeys: ${selectedRowKeys}`,
          //   "selectedRows: ",
          //   selectedRows
          // );
        },
        getCheckboxProps: (record) => ({
          disabled: record.ifsc === "Disabled User",
          ifsc: record.ifsc,
          className: "checkbox-red"
        })
      };
    
      // var dataSource2 = this.storage;
      return (
        <>
          <div className="container">
            <div className="container2">
              <Search
                onChange={(e) => setSearchVal(e.target.value)}
                placeholder="Search"
              />
            </div>
            <br /> <br />
            <Table
              rowSelection={rowSelection}
              rowKey="ifsc"
              dataSource={filteredData}
              columns={userColumns}
              loading={loading}
              pagination={
                <Pagination
                  size="small"
                  showSizeChanger
                  showQuickJumper
                  defaultCurrent={2}
                  total={500}
                  onChange={onChange2}
                />
              }
            />

link below https://codesandbox.io/s/search-in-react-table-forked-p9x544

about 4 years ago · Juan Pablo Isaza
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