Add getCurrentOpenedExpandedDepth to the table api #6114
Replies: 1 comment 1 reply
-
|
I think the difference is that You can compute that from the row model that the table is actually rendering: function getVisibleExpandedDepth(rows, depth = 0): number {
let max = 0
for (const row of rows) {
if (row.getIsExpanded() && row.subRows?.length) {
max = Math.max(max, depth + 1, getVisibleExpandedDepth(row.subRows, depth + 1))
}
}
return max
}
const depth = getVisibleExpandedDepth(table.getRowModel().rows)Because this starts from If this were added to the API, I would expect it to be named around visible rows, maybe |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
There is already a
table.getExpandedDepth()function in api but if you multiple nested expanded rows and they are all open (lets then say the getExpandedDepth() = 2). If you close the parent of that nested row thengetExpandedDepthwill still be 2 even though they arent visible right now.What would be great is to also have a function that returns the max depth for the currently expanded rows. So in my example above. if I close the parent. getExpandedDepth would still be 2. but getCurrentOpenedExpandedDepth would then be 0.
naming can be different its just the first thing I have come up with
Beta Was this translation helpful? Give feedback.
All reactions