funckymilk
funckymilk

Reputation: 21

p:column header facet is not shown when rendered attribute is used on p:column

I have a <p:dataTable>. I would like to render a <p:column> conditionally as follows:

<p:dataTable value="#{abcList}" var="abc">
  <p:column rendered="#{headerShow}">
    <f:facet name="header">
      <h:outputText value="header" />
    </f:facet>
    <h:outputText value="#{abc.hijk}" />
  </p:column>
</p:dataTable>

When #{headerShow} is false, then the column is hidden. When #{headerShow} is true, then the column is shown, but without header. When I hardcode rendered="true", then the column is shown with header.

How is this caused and how can I solve it?

Upvotes: 2

Views: 4573

Answers (1)

Patrick Trautmann
Patrick Trautmann

Reputation: 409

<f:facet name="header"> is outdated for column names. Primefaces 3.0 introduced the headerText attribute doing exactly the same.

So try this instead:

<p:column rendered="#{headerShow}" headerText="header">
  <h:outputText value="#{abc.hijk}" />
</p:column>

Upvotes: 1

Related Questions