I have a <p:datatable>
in which there is some p:column and particularly one <p:columns>
.
I'm also using one <p:columnToggler>
to let user to display or hide column.
Memorize his choices is not difficult, it's to restore dynamically his choice which is a problem, especially for <p:columns>
because there is no get/set for column inside <p:columns>
. I'm also using a pagination and columntoggler+pagination are not friends.
What is the best way to restore users choices for a <p:dataTable>
toggler ?
I use PrimeFaces 5.1.
Sorry i forgot to precise : i'm on primefaces 5.1
I found my solution ! In a first time, I put my p:columns inside a p:datatable which is inside a p:column and it's work ! The columntoggler change visibility of this whole column. So i can't hide column per column... But i also use the pagination and columntoggler/pagination didn't work very well together... I can hide a column but if i change my page (using the paginator) in datatable, the column will re-appear empty ! But if i refresh the whole page, the paginator work correctly...
that's why i used this part of solution : Primefaces ColumnToggler does'nt work with pagination
Precisely a script to check/uncheck column visibility.
An handler (dsHandler) memorize datatable states. On pre-rendering, i do something like that :
I memorize columns id, not indexes because columntoggler return columnIndex+visibility and did not pay attention to columns which are not rendered. (but datatable.getChildCount() return column number and take care of not rendered columns.
In hope that will help someone a day ;)