This question goes further, where JavaFX: BooleanBindings in connection with several EasyBind cards is stopped.
I would like to expand the factory row a bit further: in table 1, the products are presented with 1 part of the row, so there can be several rows for one product object. Now I only want to disable the row if the sum in table 2 is equal to the total number of rows. For example: A product (SKU: P1) has three rows in table 1 (all represent the sum of 1). If the product (SKU: P1) had value = -2 in table2, in table 1 it is necessary to disable 2 lines of this product object. So far, you need to activate, no matter which of the three.
I have the following code at the moment:
table1.setRowFactory(tv -> { TableRow<Product> row = new TableRow<>(); row.disableProperty().bind(Bindings.createBooleanBinding( () -> row.getItem() != null && (row.getItem().getSKU().startsWith("C") || (skuAmountLookup.containsKey(row.getItem().getSKU()) && -skuAmountLookup.get(row.getItem().getSKU()) < amounts[SKUs.indexOf(row.getItem().getSKU())] )), skuAmountLookup, row.itemProperty())); return row; });
where skuAmountLookup :
skuAmountLookup = table2.getItems().stream().collect( Collectors.toMap(Product::getSKU, Product::getAmount, (x, y) -> y, () -> FXCollections.observableHashMap()));
This only disables the rows, if the total is table 1. You can change amounts[SKUs.indexOf(row.getItem().getSKU())] to 0 , which will disable all rows when only one of the products is present.
My question is: how can I change the factory string so that disableProperty of another string is taken into account?
For more information, see JavaFX: BooleanBindings in conjunction with multiple EasyBind and JavaFX cards : disable multiple rows in a TableView based on another TableView .
javafx javafx-8 tablerow
bashoogzaad
source share