From c93b842947d5aab1d7eca1ff7f1426fe17432467 Mon Sep 17 00:00:00 2001
From: Aleksi Hietanen <aleksi@vaadin.com>
Date: Thu, 18 May 2017 09:48:10 +0300
Subject: Clarify TreeData and TreeDataProvider javadocs, improve documentation
 (#9349)

---
 documentation/components/components-treegrid.asciidoc | 15 +++------------
 1 file changed, 3 insertions(+), 12 deletions(-)

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

diff --git a/documentation/components/components-treegrid.asciidoc b/documentation/components/components-treegrid.asciidoc
index 7f444602d9..d85178507d 100644
--- a/documentation/components/components-treegrid.asciidoc
+++ b/documentation/components/components-treegrid.asciidoc
@@ -37,20 +37,11 @@ Populating a [classname]#TreeGrid# with in-memory data can be done as follows
 
 [source, java]
 ----
-Project rootProject = getRootRroject();
-
-TreeData<Project> data = new TreeData<>();
-// add a root level item with null parent
-data.addItem(null, rootProject);
-
-// Add all children for root item
-rootProject.flattened().forEach(
-       project -> data.addItems(project, project.getSubProjects()));
-
+// Initialize a TreeGrid and set in-memory data
 TreeGrid<Project> treeGrid = new TreeGrid<>();
-treeGrid.setDataProvider(new TreeDataProvider<>(data));
+treeGrid.setItems(getRootProjects(), Project::getSubProjects);
 
-// the first column gets the hierarchy indicator by default
+// The first column gets the hierarchy indicator by default
 treeGrid.addColumn(Project::getName).setCaption("Project Name");
 treeGrid.addColumn(Project::getHoursDone).setCaption("Hours Done");
 treeGrid.addColumn(Project::getLastModified).setCaption("Last Modified");
-- 
cgit v1.2.3

