title: Is it possible to do dynamic column ordering on a p:dataTable without using p:columns?
body: <p>I'm trying to dynamically display the columns of a p:dataTable: the server dictates which columns are displayed and in which order.  It doesn't look like I can set a dynamic order using the regular p:column tag so I'm stuck using the p:columns tag.  The problems with the p:columns tag are:</p>
  
  <p>1) The example in the showcase shows it working with String data, where you can map a column name to a field and then use an expression language map to retrieve the data (like a pseudo-getter)</p>
  
  <p><a href="http://www.primefaces.org/showcase/ui/data/datatable/columns.xhtml" rel="nofollow">http://www.primefaces.org/showcase/ui/data/datatable/columns.xhtml</a></p>
  
  <p>If I have different data types though, then I'm probably stuck with a bunch of panels with render attributes based on the type of the data (display Strings one way, display User objects another way, etc).  </p>
  
  <p>Example:</p>
  
  <pre><code>&lt;p:dataTable value="#{myBean.rows}" var="row"&gt;
      &lt;p:columns value="#{myBean.columns}" var="column"&gt;
  
          &lt;f:facet name="header"&gt;
               &lt;h:outputText value="#{column.header}" /&gt;
           &lt;/f:facet&gt;                
  
          &lt;!-- The content of the cell is dynamic based on the type of the field --&gt;
  
          &lt;!-- display a String field --&gt;
          &lt;h:outputText rendered="#{myBean.isStringType(column.header)}"                      
                        value="#{row[column.property]}"/&gt;
  
          &lt;!-- display a Person field --&gt;
          &lt;h:outputText rendered="#{myBean.isPersonType(column.header)}" 
                        value="#{row[column.property].name}, #{row[column.property].email}"/&gt;
  
      &lt;/p:columns&gt;
  &lt;/p:dataTable&gt;
  </code></pre>
  
  <p>2) p:columns only supports a single sortFunction/filterFunction for all columns.  Since these columns all have different types of data, they will require many different sorting and filtering methods </p>
  
  <p>A p:column easily allows for the display of different data types as well as the sorting/filtering of the data.  The only thing it can't do is have a dynamic order.</p>
  
  <p>Unless I'm missing something?  Is there a way to get this to work with p:column ?  Or is there an elegant way to have p:columns handle all of this?</p>