How do we fetch a row from a tableview in javafx ? We have a tableview with a column which holds checkboxes. Based on the checkbox selection, we have to mark a row in grey. How do we do it ?? Any help would be appreciated!
We tried the following piece of code
table1 = name of tableview
Column zero is the column with checkbox whose value has to be retrieved and based on which we have to highlight in grey
TableColumn calltypel = table1.getColumns().get(0);
calltypel.setCellFactory(column -> {
return new TableCell<Data, Boolean>() {
@Override
protected void updateItem(Boolean item, boolean empty) {
super.updateItem(item, empty);
setText(empty ? "" : getItem().toString());
TableRow<Data> currentRow = getTableRow();
if (!isEmpty()) {
if(item)
currentRow.setStyle("-fx-background-color:#C3C3C3;");
table1.setStyle("-fx-border-color: #A6A6A6; -fx-border-width:1px ;");
}
}
};
});
Our aim is : We have to tick few rows and then click on a button say "Done" and post that it should remain grey until close of the application.
The above code works but this leads to a permanent binding. we tick a checkbox and then click on Done, the row turns grey. After that the binding is permanent , i.e.,the moment we check the checkbox, its grey and on unchecking its white/pink as per the original table row column.
Please help !