4 Replies Latest reply on Sep 1, 2008 10:35 PM by hoann

    Dynamic columns with rich:columns

    hoann

      Hi all

      I'm using richfaces library in my project and have a problem with a dynamic number of columns in the sub-tables.

      For example, I have a report which contains a list of items. An item can be a row of data, or a sub-report.
      If it is a sub-report I need to display it in a sub-table.
      The number of columns in each sub-report may be varied and so does the number of sub-reports.

      The fragment of XML code I'm using is as following

       <rich:dataTable value="#{report.items}" var="item" first="1">
       <f:facet name="header">
       <h:outputText value="#{report.reportHeader}"/>
       </f:facet>
      
       <rich:subTable value="#{item.items}" var="subItem" rendered="#{item.subReport}">
      
       <!-- Display subtable columns -->
       <rich:columns value="#{item.columns}" var="subColumn" index="idx">
       <f:facet name="header">
       <h:outputText value="#{subColumn.name}" />
       </f:facet>
       <h:outputText value="#{subItem.values[idx].value}" />
       <rich:spacer />
       </rich:columns>
      
       </rich:subTable>
       </rich:dataTable>
      



      I also tried

       <rich:dataTable value="#{report.items}" var="item" first="1">
       <f:facet name="header">
       <h:outputText value="#{report.reportHeader}"/>
       </f:facet>
      
       <rich:column rendered="#{item.subReport}">
       <rich:dataTable value="#{item.items}" var="subItem">
      
       <!-- Display subtable columns -->
       <rich:columns value="#{item.columns}" var="subColumn" index="idx">
       <f:facet name="header">
       <h:outputText value="#{subColumn.name}" />
       </f:facet>
       <h:outputText value="#{subItem.values[idx].value}" />
       <rich:spacer />
       </rich:columns>
      
       </rich:dataTable>
       </rich:column>
       </rich:dataTable>
      


      But in both two cases the number of columns in sub-table is not displayed correctly.

      Can anyone help? Any idea is appreciated.
      Thanks in advance.