Hide row in JavaFX Tableview using FX-CSS?

6.1k Views Asked by At

I am having this issue where I have a JavaFX Application which uses a Tableview consisting of TableColumns and is styled by a custom css.

Everything is working great, and I can add data into my tables/cells smoothly etc. However, if I want to present the user with only partial data a css solution would be optimal (instead of manipulating the data to fit the users requirements).

I have been looking into standard css and found that the "display: none" would be the optimal solution for hiding selected rows but keeping the data intact, but there seems to be no support of this for JavaFX.

I can't seem to find a good solution, other than manually hacking methods which modify the data of the cells to fit the needs.

I have used the setCellFactory to ex. highlight text or cells in different colors, and this works fine. But no solution for not displaying cells without ruining the overall experience of my application seems to work.

Has anyone had a similar issue and found a practical solution?

2

There are 2 best solutions below

6
On

If you want to use CSS

Every Node has a visibility css property
JavaFX CSS reference
So I would try:

visibility: hidden;

But I don't know if it hides whole row or what, if there will be a trouble, you can hid the internal Label in each cell


EDIT:

And what about this workaround:

-fx-text-fill: transparent;

for each row or Label
This "hides" the text but row will stay visible
Not tested, just an idea


EDIT (2):

This can help:

-fx-cell-size: 0;

For each cell in row
But this is a part of your own idea

0
On

There is no -fx-visibility CSS property, but you could work around it by using a combination of things, like:

-fx-pref-width: 0;
-fx-opacity: 0;