PrimeFaces : How to do a dataTable with dynamic columns ?

You need use : 

<p:columns>
   {...}
</p:columns>

Full Example:

<p:dataTable id="resultadosTabela"  scrollWidth="1200px" var="s" value="#{timeLineController.selectSeasonals}" scrollable="true" frozenColumns="1" resizableColumns="true">
      <p:column headerText="Seasonals']}">
         <p:outputLabel value="#{s.name}" />
      </p:column>

      <p:columns headerText="#{col.name}" value="#{timeLineController.allColumns}" var="col" columnIndexVar="index">
         <p:outputLabel  value="#{timeLineController.getValue(s, col)}">
            <f:convertNumber type="number" maxFractionDigits="2" minFractionDigits="2"/>
         </p:outputLabel>
      </p:columns>

</p:dataTable>

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s