How to create table with nested columns #2070
Replies: 6 comments 2 replies
-
This is currently not supported in React Table as far as I know without a lot of custom work in userland. I imagine you would be better off asking this question in Discussions, so I'm going to convert it as such. |
Beta Was this translation helpful? Give feedback.
-
Could this somehow be fixed by moving |
Beta Was this translation helpful? Give feedback.
-
I needed this exact feature myself, and have a solution that seems to get the job done, but laying things out using rowSpan grates a bit against react-table's placeholder-based header layout. Currently I'm reprocessing the While a somewhat adversarial example, combining different levels of nesting can lead to undesirable results where header cells get split into two or more parts: which was accomplished by passing this header object where [
{
Header: 'Name',
columns: [
{
Header: 'First Name',
accessor: 'firstName',
},
{
Header: 'Last Name',
accessor: 'lastName',
},
],
},
{
Header: 'Info',
columns: [
{
Header: 'Age',
accessor: 'age',
},
{
Header: 'Activity',
columns: [
{
Header: 'Visits',
accessor: 'visits',
},
{
Header: 'Status',
accessor: 'status',
},
{
Header: 'Profile Progress',
accessor: 'progress',
},
]
}
]
},
] |
Beta Was this translation helpful? Give feedback.
-
@tannerlinsley is it possible to create a special column that handles its children differently? This effect can be accomplished with <table>
<thead>
<tr>
<th>Name</th>
<th>
<header>Activity</header>
<div class="grid grid-cols-3">
<div>Visits</div>
<div>Status</div>
<div>Profile Progress</div>
</div>
</th>
</tr>
</thead>
</table> The app that I'm working on is full of these tables and their management is kind of messy without a library, so I'm contemplating to write one from scratch with the basic features that we need, however, if there's a way to get it working with react-table it would be much better. The trick with the second approach is that the child columns must be present as actual columns in the table, so that they can be hidden, for example, but they must not render based on the regular flow. I see that this issue is 3 years old now, has something been added to react table that makes this possible? Thanks. |
Beta Was this translation helpful? Give feedback.
-
Hi guys! |
Beta Was this translation helpful? Give feedback.
-
I asked on their discord but didnt get any replies. @tannerlinsley any ideas? |
Beta Was this translation helpful? Give feedback.
-
I want to create a table with some nested columns like this
But got this when set columns to
const columns = [
{
Header: 'Team',
accessor: 'team',
style: {
textAlign: "center",
whiteSpace: "unset",
},
},
{
Header: 'Q1',
columns: [
{
Header: 'Jan',
accessor: 'jan',
style: {
textAlign: "center",
whiteSpace: "unset",
},
},
{
Header: 'Feb',
accessor: 'feb',
style: {
textAlign: "center",
whiteSpace: "unset",
},
},
{
Header: 'Mar',
accessor: 'mar',
style: {
textAlign: "center",
whiteSpace: "unset",
},
},
]
},
...
]
Can someone tell me how to fix this?
Beta Was this translation helpful? Give feedback.
All reactions