I have controlsfx CheckListView in my application. I am displaying my custom objects (eg: Employee). I have a list of employee objects created and wrapped in an observable list already. Now i set the observable list to my CheckListView.
checkListView.setItems(employeesObservableList);
Till here everything works fine.
Since i bound the employee objects, in the list view each checkbox value is my Employee object's toString(). I don't want the toString() value over there instead i want some other property of the employee (eno) to be displayed.
I don't see a cellValueFactory here and i don't know how to utilize the cellFactory to achieve my task, since CheckListView has its own cellFactory set already.
So my question is i want a CheckListView with checkbox values which i choose.
Thanks in advance!
The list cell used by the
CheckListView
is a standardCheckBoxListCell
fromjavafx.scene.control.cell
. So you can override thecellFactory
with something like:Note that
CheckBoxListCell<T>
has a constructor taking aCallback<T, BooleanProperty>
specifying the boolean property for a check box displaying the item;CheckListView
defines a methodgetItemBooleanProperty(T item)
that returns exactly this value, so it can be passed directly to the constructor here using a method reference.Here's a SSCCE:
Which results in