1

Please find the code link https://codesandbox.io/s/funny-phoebe-ux3e5?file=/src/nestead-table/index.js

select any records from the table and then click on the Toggle side bar the selected checkbox is getting reset always.

Please help Thanks in Advance!

2
  • 1
    It's way too much code to expect someone doing debugging. Try to isolate the problematic code and ask your question. A hint: are you using state to manage the boxes that are ticked? Commented Feb 5, 2022 at 5:35
  • As above, please reduce this to a more manageable minimum viable example. That aside, have you looked into autoResetSelectedRows? Commented Feb 7, 2022 at 4:05

1 Answer 1

1

Add autoResetSelectedRows: false, autoResetSelectedCell: false, and autoResetSelectedColumn: false. That will fix the problem you have.

function Table({ columns: userColumns, data }) {
const {
  getTableProps,
  getTableBodyProps,
  headerGroups,
  rows,
  prepareRow,
  page, // Instead of using 'rows', we'll use page,
  // which has only the rows for the active page

  // The rest of these things are super handy, too ;)
  canPreviousPage,
  canNextPage,
  pageOptions,
  pageCount,
  gotoPage,
  nextPage,
  previousPage,
  setPageSize,
  selectedFlatRows,
  state: { pageIndex, pageSize }
} = useTable(
  {
    columns: userColumns,
    data,
    initialState: { hiddenColumns: excludeColoumns, pageIndex: 0 }
    // Here you can add
    autoResetSelectedRows: false,
    autoResetSelectedCell: false,
    autoResetSelectedColumn: false,
  },
  useSortBy,
  usePagination,
  useRowSelect,
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.