Been fiddling past few days with the TreeGrid and I was wondering if there is a way to represent let’s say 2 different classes in a one Grid in a way that Class A is the root object and Class B is their parent. The amount of Class B may vary. Example:
Lets say that Class A is a workstation and Class B are the employees and I’d like to show data as follows:
- Workstation Alpha
[list]
- Employer 1
- Employer 2
[/list] - Workstation Bravo
[list]
- Employer 1
- Employer 2
- Employer 3
[/list]
I’m not even completely sure if TreeGrid is the proper way to show such data, but I as well tried the Tree component and it seems to have same limitations where I can only use one dataprovider and then the other class can’t be used since the dataprovider is for, lets say Class A. Any ideas?
EDIT: Made some progress. Now tackled with “java.lang.IllegalArgumentException: Cannot add the same item multiple times: Document name” Error message. Code below:
Tree<String> overviewTree = new Tree<>("ID-LIST");
TreeData<String> dataReal = new TreeData<>();
Attribute attribute = new Attribute();
for (Metaclass m: metaclassList) {
m.getId();
m.getNimike();
dataReal.addItems(null, m.getNimike());
try {
for (Attribute a:DBcore.getInstance().loadAttributesALL()) {
a.getMcid();
a.getMaid();
if (a.getMcid() == m.getId()) {
dataReal.addItems(m.getNimike(), a.getNimike());
}
}
} catch (SQLException e) {
}
}
overviewTree.setDataProvider(new TreeDataProvider<>(dataReal));
mainlayout.addComponent(overviewTree);