Reputation: 11
I am very new to react and wanted to handle row expand/collapse in a prime react data table. I am trying to keep only one row expanded at a time
const onRowToggle = ( e) => { setExpandedRows(e.data); }
I am using above line for that purpose. Please help!
Upvotes: 0
Views: 2899
Reputation: 10463
If you want to have only one row expanded, then remove onRowToggle
from your DataTable
component and implement the following onRowExpand
method
onRowExpand(event) {
setExpandedRows({ [event.data.id]: true });
}
Upvotes: 1