I have been trying to do a Vaadin tree grid with a more complex hierarchy. Since the documentation for this framework is very obscure and feels tad incomplete, I found this blog thread that helped me out only to get multiple children to a single parent.
However, I want to have a much more complex system where the children would have their own branches (children of children?).
For example:
So now I am stuck with this bit of code and I am unsure if I am going the right way or not.
TreeGrid<TreeDto> grid = new TreeGrid<>(TreeDto.class);
grid.setHierarchyColumn("name");
List<TreeDto> parenlist = new ArrayList<TreeDto>();
List<TreeDto> childList = new ArrayList<TreeDto>();
for(DataDepartment department : departmentLists)
{
TreeDto parent = new TreeDto(department.getDepName(), null);
for(DataGeneralSection section: sectionList)
{
childList.add(new TreeDto(section.getSection(), parent));
}
parenlist.add(parent);
}
List<TreeDto> newList = new ArrayList<TreeDto>(parenlist);
newList.addAll(childList);
newList.forEach(p -> grid.getTreeData().addItem(p.getParent(), p));
abteilungenTabs.add(grid);
Does anybody have any idea how I can achieve the hierarchy I want?