I'm using Primefaces 3.4 and trying to export a data-table with in-cell editing. It doesn't seem to work.
I have done the following:
Modified org.primefaces.component.export.Exporter
line 143 and added this:
else if (component instanceof CellEditor) { // Handle in-cell editable datatables
return exportValue(context, ((CellEditor) component).getFacet("output"));
}
This is causing an extra row on top as well as an extra column to the right of the actual cells with data. With Excel files it's OK since they are not "visible" but PDF looks bad.
Is there a way to make PF 3.4 support this without changing the source code?
No. You've to provide your custom Exporter
implementations/overrides. I've already reported this as issue 4013 several months ago. It not only mentions CellEditor
, but also HtmlGraphicImage
(we are using images to show boolean states, whose alt
we'd like to show in PDF/XML/XLS/CSV reports).
All you can do is to vote for it so that it'll hopefully get more attention, or by re-asking it on PF forum.
If the answer to the above is negative, can I make the PDF get generated without the additional row/column?
You can hide a column from export by setting the exportable="false"
attribute.
<p:column exportable="false">
Is there a way to make PF 3.4 support this without changing the source code?
Yes. There is a workaround
Make two copies of your column. First one is for users and second one is for dataExporter.
By setting exportable="false"
in first column, hide it from dataExporter.
By setting style="display: none"
in second column, hide it from users.
By the way dataExporter does not support headerText so if you need your headerText exported you have to use old style <f:facet name="header">
.
<p:column headerText="CLOSE DATE" exportable="false">
<p:cellEditor>
<f:facet name="output">
<h:outputText value="#{sale.closedate}"/>
</f:facet>
<f:facet name="input">
<h:inputText value="#{sale.closedate}"/>
</f:facet>
</p:cellEditor>
</p:column>
<p:column style="display: none">
<f:facet name="header">
CLOSE DATE
</f:facet>
<h:outputText value="#{sale.closedate}"/>
</p:column>
But this workaround is plain ugly and makes your dataTable twice in size and hard to render.
As BalusC mentioned we need to rise awareness about this issue by voting or posting in their forum.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With