Skip to content

How to group rows only if there is more than one sub-row #2775

Answered by foldedpaper
foldedpaper asked this question in Q&A
Discussion options

You must be logged in to vote

I came up with a solution, maybe it's not the best way, but it seems to work fine so far. What I do is, when rendering the table rows, make a check whether the current row has only one subRow. If it does, don't render; if it doesn't, render as normal. Like so:

{rows.map((row, i) => {
    if (row.subRows.length === 1) {
        return null
    }
    else {
        prepareRow(row)
        return (     
            [render table row]
        )
    }
})}

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by foldedpaper
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant