How do I include a field in the PrimeFaces dataExporter that does not exist in the dataTable?

0

How to include a field in the dataTable of the dataTable (Primefaces) that is not in the dataTable?

I am generating an Excel file from a dataTable with dataExporter, but I need to include a column that does not exist in the dataTable.

This dataTable is a batch item, and I need this number to be placed in a column, but I would not want it to be displayed in the list, as it would be repeated.

How to do it?

    
asked by anonymous 07.10.2015 / 19:10

1 answer

3

Marcelo, you may have already found the solution, but I'll leave an example here.

Given a dataTable any of PrimeFaces you can have both columns that are not visible on the screen but are exported with the dataExporter as having columns that are visible on the screen only, not being exported.

Column not visible on screen but present in exported file:

<p:column style="width: 10%; display: none;">
    <f:facet name="header">
        <h:outputText value="Header" />
    </f:facet>
    <h:outputText value="#{objeto.value}" escape="false"/>
</p:column>

Column visible on the screen but not exported:

<p:column style="width: 10%;" exportable="false">
    <f:facet name="header">
        <h:outputText value="Header" />
    </f:facet>
    <h:outputText value="#{objeto.value}" escape="false"/>
</p:column>
    
09.10.2015 / 17:42