0 Replies Latest reply on Nov 7, 2012 3:05 PM by sbozian

    Binding in TreeView vs TableView


      I am wondering why isn't TreeView designed like TableView with respect to the binding with the underlying data.

      In the sense that, given a Person type with 'name' StringProperty, in the case of TableView, when I pass the 'name' property (as an ObservableValue) through the cell value factory, TableView guarantees for me that:
      - whenever the 'name' property changes, the change is also reflected in the corresponding cell in the table
      - whenever the corresponding cell is edited in the table, the change is also reflected in the 'name' property

      Which means that the TableView design guarantees a sort of bidirectional binding between the underlying data and the displayed cell.

      Things seem to be different in TreeView, which apparently doesn't offer an API to pass an ObservableValue.

      Example 14-3 at the following link, shows how to implement editing in the tree:

      When I edit an item, the tree displays the modified item, but nothing updates the underlying data model (i.e. whenever I edit an employee name, I expect the 'name' property in Employee to see the change, but it doesn't).

      So to achieve that, I couldn't other than do the binding myself as follows:
      Is this a good practice, or can TreeView somehow handle this internally?

      Thank you