TreeTable Widget and Heterogeneous Data

First off, when working with TreeTable widget I have found that DefaultTreeTableModel class just accepts instances of TreeTableColumnModel. However this is an implementation rather than an interface. More importantly that implementation determines the type of the row (to be FlattenTreeTableNode). When dealing with heterogeneous data types in the same tree, I often have the need to do something different based on the domain data types.

As an example let’s say we have a tree made up of groups and fields. Besides the tree view itself, we have got another column that needs to know upon invocation of ColumnModel#getValue() which domain type is behind the row it has been asked to retrieve a value for. Let’s say groups can have comments, while fields cannot. So a decision based on the type is required.

Typically I do achieve this by extending TableNode interface so that it becomes generic like

interface CustomTableNode<DomainType> extends TableNode {
  data: DomainType;
}

Within the column model implementation (which would implement ColumnModel<CustomTableNode, …>) I can then refer to row.data without the need to cast to that type.

Second, Iam wondering if that widget’ api is flawed since a table node instance carries an identifier (id property) but is lacking type information. My point is, if I do not proceed as explained above (introducing property “data” in extending interface) the alternative is to have just an identifier. In a tree made up of heterogeneous domain types this is not sufficient as I can’t tell the involved types apart.

Hi @bjoern-quantum-vale,
Thanks for your feedback. We aware of the typing issue and also some flaws in the “Model” concept.
We are working on a new API for Table, which will be later on applied to Tree as well, that has generic typing and only interface instead of implementation.
We hope to get this out in the next month as experimental API. Would love to hear your feedback about it :slight_smile: