Thank you very much for your reply.
This is a ColumnVisibilityChangeEventHandler. It is called once I
select/deselect the column in a panel.
Hiding the data cells works flawlessly as calling "setCellStyleNames"
with the CSS class containing "display: none" works exactly as it's
meant to.
Hiding the column cells (header) however just does not work. I've
added the method-code below. I know the code is executed, because
event.getColumn().setCellStyleNames... works just as it's supposed to.
// Begin of ColumnVisibilityChangeEventHandler-methods
@Override
public void onColumnVisibilityChanged(final
ColumnVisibilityChangeEvent event) {
if (event.getColumn() != null) {
String style = "hiddenCell";
if (event.getColumn().isVisible()) {
event.getColumn().setCellStyleNames("");
cellTable.removeColumnStyleName(cellTable.getColumnIndex((Column<ItemOnCharacterDTO,?
>)event.getColumn()), ((BelongingsCellTableStyle)
cellTableResources.cellTableStyle()).cellTableHeaderHidden());
} else {
event.getColumn().setCellStyleNames(style);
cellTable.addColumnStyleName(cellTable.getColumnIndex((Column<ItemOnCharacterDTO,?
>)event.getColumn()), ((BelongingsCellTableStyle)
cellTableResources.cellTableStyle()).cellTableHeaderHidden());
}
cellTable.redrawHeaders();
cellTable.redraw();
}
}
// End of ColumnVisibilityChangeEventHandler-methods
Deleting the columns does work. However: this also means, that I
cannot show the data they should contain, once I decide to readd them.
Therefore it'd be really awesome if there was a way to make it
understand the styles..
I've used the following to apply custom styles:
interface BelongingsCellTableResources extends CellTable.Resources {
@Source(value = {CellTable.Style.DEFAULT_CSS,
"BelongingsCellTableStyle.css"})
BelongingsCellTableStyle cellTableStyle();
}
interface BelongingsCellTableStyle extends CellTable.Style {
public abstract String cellTableHeaderHidden();
}
Additionally I've included a BelongingsCellTableStyle.css in the same
package as this page. I could confirm that it sees and uses this
file..
According to Firebug the "cellTableHeaderHidden" never gets applied
(nor does "display: none" ever get applied to the header elements).
Maybe I'm doing something wrong? If you happen to have another hint,
I'd gladly try it - removing the columns is not an option though,
because the data is lost then.
Thanks!
I think I've at least found the reason why I am not able to style the
whole column with a given style.
Let's say I want to apply "display: none;" to each cell (EXCLUDING the
header), I was successful in doing so using the "setCellStyleNames"-
method from the Column<?,?>-object.
However: if I want to apply something to each cell INCLUDING the
header (or just the header), I should be able to do so using
"addColumnStyleName". But this does not work, because it applies the
style to the <col>-element within the CellTable's <colgroup> - which
is pretty much useless, because there's hardly any browser that'd
interpret the class properly let alone apply the class to each cell
(INCLUDING! the header).
This means that there are no means to change the style of the header -
at least I have not found any to date. Removing the column entirely is
not an option, as it'd lose all the data it contains.
I hope someone on here can prove me wrong, but that's what I found out
in a simple project that I've created (3 classes - I can upload it
somewhere if someone wants to have a look; I've stripped it of
anything unnecessary). I've heard there will be changes to the
celltable in 2.5 - is that so? Is there a way to test it? or at least
work around my issue? I want to be able to hide the column-header or
the entire column if I can't hide just the header (note: I want to
hide each column's header separately as I'm intending to allow the
user to hide selected columns if he decides he doesn't need certain
information).
Greetings,
Igor.