Spring
Spring

Reputation: 11835

Vaadin: databinding to Treetable

I want to use a TreeTable which some nodes in the tree will be with checkboxes and some not. My data objects are at the moment in a root java object, and already have a hierarchy. So since there are many methods to bind the data to a treetable. I am not sure which way I should choose?

Should I use a hierarchical container, Do I have to set each parent and child manually or not because it is already in a hierarchy. Should I add them as Item types or objects as they are already are, and this approach also make easy to put checkboxes to some items

Thanks

Upvotes: 1

Views: 6055

Answers (1)

user973999
user973999

Reputation:

To bind your data with the treeTable you need to use HierarchicalCOntainer beacause the hierarchy is preserved in this container and yes you have to create the hierarchy manually.

To bind your data, you have do to the following :

  1. Add all pojos in the container with hierarchical.addItem(pojo);
  2. Create manually the hierarchy. To do this you will use hierarchical.setParent(childPojo, parentPojo);
  3. Disallow children for leaves : treetable.setChildrenAllowed(leaf, false);

You can found an example of databinding here.

To have your checkBoxe in your treeTable, you can do that with a GeneratedColumn.

If your not familiar with this concept, this link will help you : 5.14.5. Generated Table

Regards, Éric

Upvotes: 5

Related Questions