-
Notifications
You must be signed in to change notification settings - Fork 59
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add methods to expand/collapse multiple levels of items without a performance penalty. #273
Conversation
Previously expanding many nodes was expensive as the flattened list was being recalculated with each expansion. Add a recursive version which recalculates the flattened list at the end.
Previously reassigning hierarchical items was expensive as the flattened list was being recalculated with each row disposal. Ignore collection changes while the rows are being disposed and recalculate the flattened rows at the end.
Failing when sorting enabled.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The new changes are performing incredibly well, @grokys rocks!
@@ -72,6 +74,33 @@ public void Expand(IndexPath index) | |||
} | |||
} | |||
|
|||
internal void ExpandRecursive(Func<TModel, bool>? filter) | |||
{ | |||
static void Expand(IReadOnlyList<HierarchicalRow<TModel>> rows, Func<TModel, bool>? filter) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm wondering if it would be interesting to expose the method Expand
for a given row. We probably need to expand some nodes inside the hierarchy, so probably having this public should be interesting.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's already exposed in the source which is where it should be called from. I think it was probably a mistake to expose the other expand and collapse methods in HirearchicalRow
(to limit API surface) so I didn't want to expose any more than was necessary.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh I think I understand what you're saying now. Yes, if you already have a row instance then I guess it could be useful. I can expose them if it would be useful to you.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If this PR is accepted, we won't need it. But I still think it's a useful API for others if one needs to recursively expand a non-root node :-).
It didn't make much sense that returning `true` from the `ExpandRecursive` predicate caused the node to be expanded, but returning `false` didn't cause it to be collapsed. This API allows one to expand and collapse from the same method.
Tested the new methods to expand/collapse a large number of rows (~60k) with a good amount of depth. The methods work as expected and the performance is greatly improved |
Included in recent 11.0.10. |
Previously the only way to e.g. expand all items in a hierarchical
TreeDataGrid
was to expand each item one by one. This was very slow as after each expansion the flattened list of rows needed to be recalculated.Added the follow methods which speed this up:
ExpandAll
: to expand all rows recursivelyExpandCollapseRecursive
: to expand or collapse all rows recursively based on a predicateCollapseAll
: to collapse all rows recursively