Questions tagged [react-table-v7]

Hooks for building fast and extendable tables and datagrids for React. v7 was a major refactor of the library, eliminating the component for a headless hook-based data organization utility. For questions about the component and other deprecated methods from previous versions, use [react-table-v6]. For questions about the most recent version of react-table or the TanStack Table useReactTable hook, use [react-table].

The most recent version of react-table is the @tanstack/react-table adapter of the TanStack Table libary. This tag is specifically for questions about v7, which was a major refactor over previous versions, and differs in other ways from v8 and beyond.

Website

https://react-table-v7.tanstack.com/

Demos

https://react-table-v7.tanstack.com/docs/examples/basic

Docs

https://react-table-v7.tanstack.com/docs/overview

Example

const {
  getTableProps,
  getTableBodyProps,
  headerGroups,
  rows,
  prepareRow,
} = useTable({
  columns,
  data,
})

// Render the UI for your table
return (
  <table {...getTableProps()}>
    <thead>
      {headerGroups.map(headerGroup => (
        <tr {...headerGroup.getHeaderGroupProps()}>
          {headerGroup.headers.map(column => (
            <th {...column.getHeaderProps()}>{column.render('Header')}</th>
          ))}
        </tr>
      ))}
    </thead>
    <tbody {...getTableBodyProps()}>
      {rows.map((row, i) => {
        prepareRow(row)
        return (
          <tr {...row.getRowProps()}>
            {row.cells.map(cell => {
              return <td {...cell.getCellProps()}>{cell.render('Cell')}</td>
            })}
          </tr>
        )
      })}
    </tbody>
  </table>
)
227 questions
2
votes
1 answer

How to add dropdown to react-table on click of icon

I am using react table 7.0 , How can i add and iconColumn , and on click of that , need to show an dropdown. { Header: "", accessor: "actionColumn", disableSortBy: true, Cell: ({ original }) => ( …
bharath
  • 111
  • 1
  • 2
  • 15
2
votes
4 answers

`react-table` v7 how to preserve a grouping's sort order whilst the rows of the groups are sorted

I have a table that is grouped with an initial sort order applied. I want to be able to sort on the UI but at the same time preserve the initial grouping sort order. So it would be like a multi-sort but that one sorting rule is always applied to the…
RyanP13
  • 7,413
  • 27
  • 96
  • 166
2
votes
2 answers

How to add types to React Table IndeterminateCheckbox method

I'm really a beginner at typescript world and, I'm currently using React Table library that has no types by default on documentation. So, I would like to ask your help to add the types to IndeterminateCheckbox method. const IndeterminateCheckbox =…
Ivan Vinicius
  • 51
  • 1
  • 4
2
votes
2 answers

React-Table make one cell a link

I am working on a react-app that displays data in a table format. I am using react-table to format the data. I want to make one of the cells a link to a project description page. I do not want the whole row to be 'clickable'. I am retrieving the…
timbo245
  • 175
  • 1
  • 14
2
votes
0 answers

React Table - Toggle Row Expanded on Two Different Columns

I'm using react-table (7.5.0) to render some tables within an application. I've obfuscated and leaned out my code so missing bracket's or incorrect syntax may exist. On a simple level, I have a single row, two columns. Each column has a really long…
TheGoldenD0nut
  • 123
  • 1
  • 13
2
votes
1 answer

React-table exclude default column filter

I have a default column filter and I'm wondering if there is a way from excluding it from one column. You can check an example from React-table that I'm using:…
Shira
  • 394
  • 1
  • 6
  • 21
2
votes
1 answer

ReactTable v7 - noDataText not showing on empty data (using useTableHook)

I am trying to display some data using the react table v7. It works perfectly using the useTable hook, except it just displays an empty table, without a noDataText as expected. import React, { useContext, useEffect, useMemo } from 'react' import { …
Gabriel
  • 182
  • 4
  • 9
2
votes
2 answers

How can I set the default state of a checkbox based on value in firestore in react table

How can I set the default state of checkboxes based on values from firestore in React Table. Sorry if the question is a bit basic. I have read through the official docs and couldn't really make sense of how to do it, I've also looked at a good few…
2
votes
1 answer

React-Table - How to combine useResizeColumns with sticky Header in Material-UI table

In the latest version (7.5.x) of React-Table, is there a way to add the column resizing to a Material-UI table without breaking the 'Sticky Header' property of the Material-UI Table? On one hand, adding 'useFlexLayout' or 'useBlockLayout' breaks the…
Vladi Feldman
  • 872
  • 1
  • 8
  • 16
2
votes
1 answer

ReactJS - Checkbox column in react-table doesn't work

I have added an editable react-table (https://codesandbox.io/s/github/tannerlinsley/react-table/tree/master/examples/kitchen-sink) to my project and everything works fine. But when I added a column with checkboxes, and tick the checkboxes and go to…
Asela
  • 303
  • 1
  • 5
  • 16
1
vote
1 answer

Checkbox Default Checked in React table is not working

I want to mark the checkbox checked inside a subComponent with the help of forwardref but i am not getting the result. I have tried defaultChecked = {true} defaultValue = {true} inside input field but didn't succeed. Here is the checkbox…
1
vote
0 answers

How can I make react-table v7 multisort on two columns

I'm using react-table v7.8.0 to create a table with 4 columns. I'd like the the table to be sorted by columns date and views. My problem is that the table is only being sorted by the date column. I have some pagination and manual sorting that…
John
  • 949
  • 1
  • 9
  • 20
1
vote
0 answers

Sort multiple React Table instances simultaneously

I'm new to React and I'm trying to sort two React Table instances simultaneously. I have searched all over the place, but I haven't found anything about it so far. Simplified scenario for the setup. Both tables have the same columns but different…
C.Fletcher
  • 11
  • 2
1
vote
1 answer

How can I create a number range filter in react table v7?

How can I create a number range filter in react table v7? Here is my relevant column definition, and filter function. // The Filter function import { Box, Input } from '@mui/material'; const NumberFilter = ({ column, data }) => { const {…
GNG
  • 1,341
  • 2
  • 23
  • 50
1
vote
0 answers

How can I pass the number of rows on the page into a column definition with react table v7?

I have a table built on react table v7 with pagination enabled. I'd like to display the indeterminate icon in my header (select all) checkbox when only some of the rows on a page are selected. In order to achieve this, I can compare the number of…
GNG
  • 1,341
  • 2
  • 23
  • 50