-
So, here is a codesanbox fork from the expanding example, where I just have, to my understanding, the most basic implementation of expanding rows: In here, I use My problem is that, IF I change what am I doing wrong here? |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 7 replies
-
Replace
|
Beta Was this translation helpful? Give feedback.
-
Can we create a custom expand row view in that? |
Beta Was this translation helpful? Give feedback.
-
Approach 1 This is the table instance const [expanded, setExpanded] = useState({}); const table = useReactTable({ onExpandedChange: setExpanded, useEffect(() => { table.toggleAllRowsExpanded(true); //This will auto expand all the rows by default }, [data]); Approach 2 Just pass in the default value of expanded as true as shown below const [expanded, setExpanded] = useState(true); |
Beta Was this translation helpful? Give feedback.
Replace
onClick: row.toggleExpanded
byonClick: () => row.toggleExpanded()
onClick
implicitly sendReact.MouseEventHandler<HTMLButtonElement>
as a parameter, so the way you do it is the equivalent ofonClick: (event: React.MouseEventHandler<HTMLButtonElement>) => row.toggleExpanded(event)
whereevent
will always betrue
, which make the row openable but not closable.