aboutsummaryrefslogtreecommitdiffstats
path: root/documentation/components/components-treegrid.asciidoc
diff options
context:
space:
mode:
authorAleksi Hietanen <aleksi@vaadin.com>2017-05-16 11:57:02 +0300
committerPekka Hyvönen <pekka@vaadin.com>2017-05-16 11:57:02 +0300
commitefa7f5a4d069556061ba4ceef4fb4d76dae84ef4 (patch)
tree767b0fdb3146930919cec37e5eaab75422b0867d /documentation/components/components-treegrid.asciidoc
parenteb743d965278d263a4c496bb4e39c067fe2b1a8c (diff)
downloadvaadin-framework-efa7f5a4d069556061ba4ceef4fb4d76dae84ef4.tar.gz
vaadin-framework-efa7f5a4d069556061ba4ceef4fb4d76dae84ef4.zip
Refactor common methods in in-memory data providers (#9308)
* Refactor common methods of InMemoryHierarchicalDataProvider and ListDataProvider to a single interface * Rename HierarchyData and InMemoryHierarchicalDataProvider, introduce HasHierarchicalDataProvider * Additionally adds a helper method for recursive constructing TreeData with a child item provider.
Diffstat (limited to 'documentation/components/components-treegrid.asciidoc')
-rw-r--r--documentation/components/components-treegrid.asciidoc16
1 files changed, 8 insertions, 8 deletions
diff --git a/documentation/components/components-treegrid.asciidoc b/documentation/components/components-treegrid.asciidoc
index d5659cb556..7f444602d9 100644
--- a/documentation/components/components-treegrid.asciidoc
+++ b/documentation/components/components-treegrid.asciidoc
@@ -30,7 +30,7 @@ image::img/tree-grid-basic.png[width=70%, scaledwidth=100%]
[[components.treegrid.data]]
== Binding to Data
-[classname]#TreeGrid# is used by binding it to a hierarchical data provider. The data provider can be based on in-memory or back end data. For in-memory data, the [classname]#InMemoryHierarchicalDataProvider# can be used, and for loading data from a back end, you need to implement three methods from the [interfacename]#HierarchicalDataProvider# interface. Usage of both data providers is described in
+[classname]#TreeGrid# is used by binding it to a hierarchical data provider. The data provider can be based on in-memory or back end data. For in-memory data, the [classname]#TreeDataProvider# can be used, and for loading data from a back end, you need to implement three methods from the [interfacename]#HierarchicalDataProvider# interface. Usage of both data providers is described in
<<dummy/../../../framework/datamodel/datamodel-hierarchical.asciidoc#datamodel.hierarchical,"Hierarchical Data">>.
Populating a [classname]#TreeGrid# with in-memory data can be done as follows
@@ -39,7 +39,7 @@ Populating a [classname]#TreeGrid# with in-memory data can be done as follows
----
Project rootProject = getRootRroject();
-HierarchyData<Project> data = new HierarchyData<>();
+TreeData<Project> data = new TreeData<>();
// add a root level item with null parent
data.addItem(null, rootProject);
@@ -48,7 +48,7 @@ rootProject.flattened().forEach(
project -> data.addItems(project, project.getSubProjects()));
TreeGrid<Project> treeGrid = new TreeGrid<>();
-treeGrid.setDataProvider(new InMemoryHierarchicalDataProvider<>(data));
+treeGrid.setDataProvider(new TreeDataProvider<>(data));
// the first column gets the hierarchy indicator by default
treeGrid.addColumn(Project::getName).setCaption("Project Name");
@@ -56,18 +56,18 @@ treeGrid.addColumn(Project::getHoursDone).setCaption("Hours Done");
treeGrid.addColumn(Project::getLastModified).setCaption("Last Modified");
----
-The [classname]#HierarchyData# class can be used to build the hierarchical data structure,
-and it can then be passed on to [classname]#InMemoryHierarchicalDataProvider#. It is simply a hierarchical
+The [classname]#TreeData# class can be used to build the hierarchical data structure,
+and it can then be passed on to [classname]#TreeDataProvider#. It is simply a hierarchical
collection, that the data provider uses to populate the [classname]#TreeGrid#.
The [methodname]#setItems# method in [classname]#TreeGrid# can be used to set the root level items. Internally
-an [classname]#InMemoryHierarchicalDataProvider# with [classname]#HierarchyData# is used. If at any time you want to modify the in-memory data in the grid, you may do it as follows
+an [classname]#TreeDataProvider# with [classname]#TreeData# is used. If at any time you want to modify the in-memory data in the grid, you may do it as follows
[source, java]
----
-InMemoryHierarchicalDataProvider<Project> dataProvider = (InMemoryHierarchicalDataProvider<Project>) treeGrid.getDataProvider();
+TreeDataProvider<Project> dataProvider = (TreeDataProvider<Project>) treeGrid.getDataProvider();
-HierarchyData<Project> data = dataProvider.getData();
+TreeData<Project> data = dataProvider.getData();
// add new items
data.addItem(null, newProject);
data.addItems(newProject, newProject.getChildren());