From 6384bc7dee5ccbaaafbbf569b758b3e6fd8a2c8b Mon Sep 17 00:00:00 2001
From: Teemu Suo-Anttila <tsuoanttila@users.noreply.github.com>
Date: Thu, 23 Mar 2017 15:28:37 +0200
Subject: Add feature to disable collapsing items in TreeGrid (#8879)

Fixes #8846
---
 documentation/components/components-treegrid.asciidoc | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

(limited to 'documentation/components/components-treegrid.asciidoc')

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.
-- 
cgit v1.2.3

