Primefaces Column Toggler (Hide specified columns initially)

Primefaces column toggler component is a helper component of datatable to toggle the visibility of columns. On page load, column chooser finds all columns of datatable and generates the ui at the client side. If toggleable option of a column is set to false, these columns are ignored while generating the ui. However, in some cases if you need a datatable which has huge number of columns, you do not want to show them initially, but you want to give the flexibility to users that they can select the columns they want after initial page load.

From this requirement, I want to prepare an example which is based on the primefaces showcase application. ( All the backend codes (Car, CarService, CarBean) are the same. The tricky part is at the client side which is stated at the bottom.

ColumnToggler.prototype.render() function of Primefaces is overriden in a way that if columns has a styleClass “not-show-at-start” they will be hidden at the client side.

Leave a Reply

Your email address will not be published. Required fields are marked *