8 Replies Latest reply on Aug 22, 2008 2:31 AM by vlad.kamensky

    dymanically create datatable and column

    guiltyxsin

      Hi all,

      I want to dymanically create tables and within each table I also dymanically create columns.

      I am not sure if I am implementing it the correct way.
      The following is my html code:

      <a4j:repeat value="#{testlist}" var="tlist">
      
      <rich:dataTable value="#{tlist}" var="t" border="1" width="450"
      onRowMouseOver="this.style.backgroundColor='#F1F1F1'"
      onRowMouseOut="this.style.backgroundColor='#{a4jSkin.tableBackgroundColor}'">
      
       <f:facet name="header">
       <h:outputText value="#{tlist.name}" /> </f:facet>
      
       <rich:column>
       <f:facet name="header">
       <h:outputText value="Date" /> </f:facet>
       </rich:column>
      
       <a4j:repeat value="#{tlist.params}" var="p">
       <rich:column>
       <f:facet name="header">
       <h:outputText value="p.paramname" /> </f:facet>
       </rich:column>
       </a4j:repeat>
      
      </rich:dataTable>
      
      </a4j:repeat>
      


      The testlist is a list of test:
      public class Test {
      
       private String name;
       private List<ParamColumn> params;
      
       public String getName() {return name;}
       public void setName(String name) { this.name = name; }
      
       public List<ParamColumn> getParams() {return params;}
       public void setParams(List<ParamColumn> params) {this.params=params;}
      }
      


      And for the ParamColumn :
      public class ParamColumn {
       String paramname;
      
       public String getParamName() { return paramname; }
       public void setParamName(String param) { this.paramname=param; }
      }
      


      The result is a list of tables with correct header but only one column "Date" and didn't create any other columns with paramname as header.

      Is it possible to do it?
      Thanks for any suggestions in advance!!

      Regards,
      Andy