Reputation: 73
I have a situation here. I am using prime faces 2.2 where i am showing a data-table on a screen after pulling data from database and displaying the same on data-table. i have 80 columns to retrieve from database but only showing few of them on data-table due to screen size constraints. But while exporting the data-table to excel, i need to export all the 80 columns. Please advise how can we do this the easiest way..Thanks.
Upvotes: 3
Views: 3211
Reputation: 5356
One way which we used is have those column as part of datatable definition and then hide them from client side. That way, they are still part of the meta data for datatable, but not visible on the UI. Here is how we did.
<p:column headerText="Group Name" width="0" styleClass="vd-hidden-column">
<h:outputText value="#{managedbean.groupName}" />
</p:column>
Then, we applied the CSS for .vd-hidden-column
as below.
.vd-hidden-column {
display: none;
width: 0;
height: 0;
}
Voila. The columns is hidden on the UI. But, they will be part of your excel/csv export.
Upvotes: 7