Issue
I am new to JavaFx. In my application i have a requirement to create a table view with Action button in one of the column of rows. I used sample code from here and implemented the table view with Button and it works perfectly fine.
Now when i add pagination to it using example given on this link here the table view is rendered with pagination, but i see the button is getting added for blank rows in action column as well where as remaining columns are blank.
One more observation, when i have just 1 page in pagination and less number of records then the records allowed per page then it works fine, buttons are not rendered for blank rows, the moment number of records grows to more then one page this problem happens.
Can someone help me understand why this is happening?
Solution
There is a bug in the code you linked. The updateItem
method in the cell implementation needs to handle the case of empty cells. Try this instead:
@Override protected void updateItem(Boolean item, boolean empty) {
super.updateItem(item, empty);
if (empty) {
setGraphic(null);
} else {
setContentDisplay(ContentDisplay.GRAPHIC_ONLY);
setGraphic(paddedButton);
}
}
Answered By - James_D
Answer Checked By - Robin (JavaFixing Admin)