From d1fa1a3efe08e0843a38947dcd8ffe65e04ed12c Mon Sep 17 00:00:00 2001 From: Aleksi Hietanen Date: Tue, 21 Mar 2017 15:53:59 +0200 Subject: Add collapse and expand events to TreeGrid (#8889) Closes #8760 --- documentation/components/components-treegrid.asciidoc | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'documentation/components') diff --git a/documentation/components/components-treegrid.asciidoc b/documentation/components/components-treegrid.asciidoc index b0e28fee5f..d3a431c3e9 100644 --- a/documentation/components/components-treegrid.asciidoc +++ b/documentation/components/components-treegrid.asciidoc @@ -93,3 +93,16 @@ treeGrid.addColumn(Project::getHoursDone).setCaption("Hours Done"); treeGrid.setHierarchyColumn("name"); ---- +== 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. +The expand and collapse listeners can be added as follows: + +[source, java] +---- +treeGrid.addExpandListener(event -> log("Item expanded: " + event.getExpandedItem())); +treeGrid.addCollapseListener(event -> log("Item collapsed: " + event.getCollapsedItem())); +---- + +The return types of the methods `getExpandedItem` and `getCollapsedItem` are the same as the type of the [classname]#TreeGrid# the events originated from. +Note that collapse listeners will not be triggered for any expanded subtrees of the collapsed item. -- cgit v1.2.3