TreeTableに親子リンクを作成する際に問題があります。 Vaadin、TreeTable。 setParent
table.setContainerDataSource(new TempPeopleContainer(((MyUI) UI.getCurrent()).peopleService.getItemList()));
table.setParent(1,0);
データソース
の設定はどのようにしてデータソースの設定のこの種のオブジェクトのIDを設定することができますか?私はTreeTableの要素に明示的なIdがありません。
private class TempPeopleContainer extends FilterableListContainer<People> {
public TempPeopleContainer(final Collection<People> collection) {
super(collection);
}
// This is only temporarily overridden until issues with
// BeanComparator get resolved.
@Override
public void sort(final Object[] propertyId, final boolean[] ascending) {
final boolean sortAscending = ascending[0];
final Object sortContainerPropertyId = propertyId[0];
Collections.sort(getBackingList(), (o1, o2) -> {
int result = 0;
if ("lastname".equals(sortContainerPropertyId)) {
result = o1.getLastname().compareTo(o2.getLastname());
}
if (!sortAscending) {
result *= -1;
}
return result;
});
}
}
I:
TreeTable ttable = new TreeTable("My TreeTable");
ttable.addContainerProperty("Name", String.class, null);
ttable.addContainerProperty("Number", Integer.class, null);
ttable.setWidth("20em");
// Create the tree nodes and set the hierarchy
ttable.addItem(new Object[]{"Menu", null}, 0);
ttable.addItem(new Object[]{"Beverages", null}, 1);
ttable.setParent(1, 0);
ttable.addItem(new Object[]{"Foods", null}, 2);
ttable.setParent(2, 0);
が、それは私のTempPeopleContainerクラスの定義です:
は、ここでは、(私のアプリからのコードではありません)各要素のidのの "明確に" の定義を参照することができexample from vaadin、あります私の質問がはっきりすることを願ってありがとう。
私ははっきりと理解していましたが、私はテーブル – zond
にIDとして豆からIDを設定することができますどのように私はあなたのための例を追加しました。 setParent()はアイテムIDであるObjectを受け入れます。アイテムIDは、アイテム自体のようなものである可能性があります。うまくいけば良いequals()メソッドを実装しているので、すべてうまくいくはずです。 – wolle