aboutsummaryrefslogtreecommitdiffstats
path: root/documentation/components
diff options
context:
space:
mode:
Diffstat (limited to 'documentation/components')
-rw-r--r--documentation/components/components-treegrid.asciidoc16
1 files changed, 16 insertions, 0 deletions
diff --git a/documentation/components/components-treegrid.asciidoc b/documentation/components/components-treegrid.asciidoc
index d3a431c3e9..f3c2058f03 100644
--- a/documentation/components/components-treegrid.asciidoc
+++ b/documentation/components/components-treegrid.asciidoc
@@ -93,6 +93,22 @@ treeGrid.addColumn(Project::getHoursDone).setCaption("Hours Done");
treeGrid.setHierarchyColumn("name");
----
+== Prevent Node Collapsing
+
+[classname]#TreeGrid# supports setting a callback method that can allow or prevent the user from collapsing an expanded node.
+It can be set with [methodname]#setItemCollapseAllowedProvider# method, that takes a [interfacename]#SerializablePredicate#.
+For nodes that cannot be collapsed, the [literal]#++collapse-disabled++# class name is applied to the expansion element
+
+Avoid doing any heavy operations in the method, since it is called for each item when it is being sent to the client.
+
+Example using a predefined set of persons that can not be collapsed:
+[source, java]
+----
+Set<Person> alwaysExpanded;
+personTreeGrid.setItemCollapseAllowedProvider(person ->
+ !alwaysExpanded.contains(person));
+----
+
== Listening to Events
In addition to supporting all the listeners of the standard [classname]#Grid#, [classname]#TreeGrid# supports listening to the expansion and collapsing of items in its hierarchy.