title: Vaadin, TreeTable. setParent
body: <p>I have a problem with creating parent-child link in my TreeTable.</p>
  
  <p>Setting of DataSource</p>
  
  <pre><code>table.setContainerDataSource(new TempPeopleContainer(((MyUI) UI.getCurrent()).peopleService.getItemList()));
  table.setParent(1,0);
  </code></pre>
  
  <p>How can I set id of Object in this kind of DataSource setting? I've no explicit Id for elements of TreeTable.</p>
  
  <p>Here is <a href="https://github.com/vaadin/book-examples/blob/master/src/com/vaadin/book/examples/component/TreeTableExample.java" rel="nofollow noreferrer">example from vaadin</a> , where you can see "clearly" definition of Id's for each element (code not from my app):</p>
  
  <pre><code> 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);
  </code></pre>
  
  <p>it's my TempPeopleContainer class definition:</p>
  
  <pre><code>private class TempPeopleContainer extends FilterableListContainer&lt;People&gt; {
      public TempPeopleContainer(final Collection&lt;People&gt; 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) -&gt; {
              int result = 0;
              if ("lastname".equals(sortContainerPropertyId)) {
                  result = o1.getLastname().compareTo(o2.getLastname());
              }
              if (!sortAscending) {
                  result *= -1;
              }
              return result;
          });
      }
  }
  </code></pre>
  
  <p>I hope my question is clear. Thanks.</p>