Skip to content

Commit

Permalink
make test page expandable rows interactive
Browse files Browse the repository at this point in the history
  • Loading branch information
pan-kot committed Jan 20, 2025
1 parent dc6d8ed commit b58991d
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions pages/table/editable.page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,8 @@ const Demo = forwardRef(
setClean();
};

const [expandedItems, setExpandedItems] = useState<DistributionInfo[]>([]);

return (
<Table
ref={tableRef}
Expand All @@ -297,10 +299,19 @@ const Demo = forwardRef(
expandableRows={
expandableRows
? {
getItemChildren: () => [],
isItemExpandable: () => true,
expandedItems: [],
onExpandableItemToggle: () => {},
getItemChildren: item => [
{ ...item, Id: item.Id + '-1' },
{ ...item, Id: item.Id + '-2' },
],
isItemExpandable: item => !item.Id.endsWith('-1') && !item.Id.endsWith('-2'),
expandedItems,
onExpandableItemToggle: ({ detail }) => {
if (detail.expanded) {
return setExpandedItems(prev => [...prev, detail.item]);
} else {
return setExpandedItems(prev => prev.filter(item => item !== detail.item));
}
},
}
: undefined
}
Expand Down

0 comments on commit b58991d

Please sign in to comment.