问题
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?
回答1:
<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>
来源:https://stackoverflow.com/questions/12948799/pcolumn-header-facet-is-not-shown-when-rendered-attribute-is-used-on-pcolumn