How to include a field in the First Faces dataset that does not exist in the datatable?

Asked

Viewed 332 times

0

How to include a field in the dataPath (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 datatable.

This datatable are items of a lot and I need this number to be placed in a column, but I would not like it to be displayed in the list, because they would be repeated.

How to do?

  • 1

    Dude I don’t know if there’s a way, a solution would be to put the fields in the dataTable and give a rendered="false" so they don’t show off.

  • With rendered="false" didn’t work.

  • A colleague passed me the solution, tested and worked. How to do? Add normally the column in the datatable and put style="display:nome" then include in datatable scrollable="true"so that it does not generate empty columns at the end of the generated excel file.

  • Yeah, anything try that too: <h:outputText value="#{bean.exemplo}" id="exemplo" style="visibility:hidden;">

1 answer

3


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

Given a datatable any of the Primefaces you can have so many 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 the screen but present in the 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 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>
  • Renan, it also worked out thanks

Browser other questions tagged

You are not signed in. Login or sign up in order to post.