feat(material/tree): removeNode method #29350
Labels
area: cdk/tree
feature
This issue represents a new feature or feature request rather than a bug or bug fix
P3
An issue that is relevant to core functions, but does not impede progress. Important, but not urgent
Feature Description
There is a method for adding a node,
insertNode()
, but there is no method for deleting.At the moment this can only be done by completely reinitializing the `data' object that is passed to the mat tree.
Use Case
One use case is in which there is a tree that can be modified by the user by adding and deleting nodes, without changing the state of the existing nodes.
For example, if the user expands the nodes and then wants to delete one of them, currently this can be implemented by saving the open nodes in a separate state, re-initializing the
dataSource.data
object after the desired node has been deleted and then restoring the open nodes .Usage:
This works ok for cases where the tree does not have many elements, but if there are dozens of nodes then this process takes from a few milliseconds to a few seconds, which does not lead to a very pleasant experience.
The text was updated successfully, but these errors were encountered: