Customize export output format of p:dataTable

J Dev Source

I have a Primefaces dataTable where one column is having three output texts and one command button with tooltip. The button appears with output labels as

This is for export label. This is for [email protected]f9

How can I not include/print this command button with tooltip to export the dataTable to excel?

I can't move the command button to new column for business case.



answered 6 months ago Kukeltje #1

In PrimeFaces you can override the exported content of a column bij using the exportFunction attribute (which is in the documentation). If you'd read this in the documentation, you'd easily have found by using google. In it, an example is given of how to override the 'exported value' of a column:


<p:column exportFunction="#{testView.exportBrand}">
   <f:facet name="header">
       <h:outputText value="Brand" />
  <h:outputText value="#{car.brand}" />


public String exportBrand(UIColumn column) {
    String value = "";
    for(UIComponent child: column.getChildren()) {
        if(child instanceof ValueHolder) {
            value = ComponentUtils.getValueToRender(FacesContext.getCurrentInstance(), child);

    return value + "_TEST";

Just extend this and in the for loop only export things you want to export.

comments powered by Disqus