mardi 10 mai 2016

Checkboxes only on Leafs of TreeTableView in JavaFX

I have a TreeTableIView with 3 levels. I want to show Checkboxes on leafs only, while all other cells remain empty. So far, I have created 2 columns:

The first column holds the hierarchy:

      TreeTableColumn<AttributeRow, String> attributeColumn = new TreeTableColumn<>("Attributes");
        attributeColumn.setPrefWidth(200);
        attributeColumn.setCellValueFactory(
            (TreeTableColumn.CellDataFeatures<AttributeRow, String> param) -> 
                new ReadOnlyStringWrapper(param.getValue().getValue().getAttributeName())
        );

The second columns shall contain the CheckBoxes on leafs only:

           TreeTableColumn<AttributeRow, Boolean> companyColumn = new TreeTableColumn<>(companyGroup);
           companyColumn.setPrefWidth(200);
           companyColumn.setCellFactory(CheckBoxTreeTableCell.forTreeTableColumn(companyColumn));
           companyColumn.setCellValueFactory(param -> {
               if (param.getValue().getValue().getCompanyGroups() == null) {
                   return new SimpleBooleanProperty(true);
               } else {                

                   return new SimpleBooleanProperty(false); 
               }
           });

This is what I want to achieve:

enter image description here

Is there a way to only show CheckBoxes on leafs, while the other cells are empty? Thanks!

Aucun commentaire:

Enregistrer un commentaire