4 Replies Latest reply on Apr 18, 2011 1:39 PM by cavinator

    rich:dataTable how to print column headers multiple times

    cavinator

      Hi,

       

      Is there a way to reprint column headers before every single records in <rich:dataTable> ?

       

      The senario is that i have <rich:dataTable> that display Travel Log records.  Right below each Travel Log record I display Travel legs using <rich:subTable>.  To easily view and separate Travel Log and the previous Travel Leg records I want to reprint the Travel Log headers.  Example of the code is below.

       

      <rich:dataTable id="travelLog" var="_travelLog"

      ...

          <rich:column>

               <f:facet name="header">Travel Log Name</f:facet>

               <h:outputText value="#{_travelLog.name}"/>       

          </rich:column>

      ...

           <rich:subTable id="travelLeg" value="_travelLeg"

           ...

               <rich:column>

               <f:facet name="header">Travel From</f.facet>

               <h:outputText value="#{_travelLeg.fromLocation}"/>

               </rich:column>

           ...

           </rich:subTable>

      ...

      </rich:dataTable>

       

      Thank you for your help,

       

      Cavin

       

        • 1. rich:dataTable how to print column headers multiple times
          ilya_shaikovsky

          so the header should appear above every subtable columns? I checked under 3.3.3 and wortks fine for me.

          • 2. rich:dataTable how to print column headers multiple times
            cavinator

            yes and that is the version i have too.  Currently, my temporary solution is to have <ui:repeat> wrap around <rich:dataTable> as shown below.  Would you show me your solution?

             

            <ui:repeat value="{_travelLogs}" var="_log"> <!-- get a list of all the travel logs -->

                 <rich:dataTable value="{ get one record of travel log at a time feeded by _log}  var="_travelLog" ...>

                    ...

                 <rich:subTable id="travelLeg" value="_travelLog.travelLegs"

                 ...

                 </rich:subTable>

                </rich:dataTable>    

            </ui:repeat>

             

            thank you,

            Cavin

            • 3. rich:dataTable how to print column headers multiple times
              ilya_shaikovsky

              with that code:

              <ui:composition xmlns="http://www.w3.org/1999/xhtml"

                    xmlns:ui="http://java.sun.com/jsf/facelets"

                    xmlns:h="http://java.sun.com/jsf/html"

                    xmlns:f="http://java.sun.com/jsf/core"

                    xmlns:a4j="http://richfaces.org/a4j"

                    xmlns:rich="http://richfaces.org/rich">

               

                                                      <rich:dataTable

                                                                onRowMouseOver="this.style.backgroundColor='#F1F1F1'"

                                                                onRowMouseOut="this.style.backgroundColor='#{a4jSkin.tableBackgroundColor}'"

                                                                cellpadding="0" cellspacing="0"

                                                                width="700" border="0" var="record" value="#{report.expReport.records}">

               

                                                                <f:facet name="header">

                                                                          <rich:columnGroup>

                                                                                    <rich:column rowspan="2">

                                                                                              <rich:spacer />

                                                                                    </rich:column>

                                                                                    <rich:column colspan="3">

                                                                                              <h:outputText value="Expenses" />

                                                                                    </rich:column>

                                                                                    <rich:column rowspan="2">

                                                                                              <h:outputText value="subtotals" />

                                                                                    </rich:column>

                                                                                    <rich:column breakBefore="true">

                                                                                              <h:outputText value="Meals" />

                                                                                    </rich:column>

                                                                                    <rich:column>

                                                                                              <h:outputText value="Hotels" />

                                                                                    </rich:column>

                                                                                    <rich:column>

                                                                                              <h:outputText value="Transport" />

                                                                                    </rich:column>

                                                                          </rich:columnGroup>

                                                                </f:facet>

               

                                                                <rich:column  colspan="5">

                                                                <h:outputText value="#{record.city}" /></rich:column>

               

               

                                                                <rich:subTable

                                                                          onRowMouseOver="this.style.backgroundColor='#F8F8F8'"

                                                                          onRowMouseOut="this.style.backgroundColor='#{a4jSkin.tableBackgroundColor}'"

                                                                          var="expense" value="#{record.items}">

                                                                          <rich:column>

                                                                                    <f:facet name="header">day</f:facet>

                                                                                    <h:outputText value="#{expense.day}"></h:outputText>

                                                                                    <f:facet name="footer">

                                                                                              <rich:spacer />

                                                                                    </f:facet>

                                                                          </rich:column>

                                                                          <rich:column>

                                                                                    <f:facet name="header">meals</f:facet>

                                                                                    <h:outputText value="#{expense.meals}"><f:convertNumber   pattern="$####.00"  /></h:outputText>

                                                                                    <f:facet name="footer">

                                                                                              <h:outputText value="#{record.totalMeals}"><f:convertNumber  pattern="$####.00" /></h:outputText>

                                                                                    </f:facet>

                                                                          </rich:column>

                                                                          <rich:column>

                                                                                    <f:facet name="header">hotels</f:facet>

                                                                                    <h:outputText value="#{expense.hotels}"><f:convertNumber  pattern="$####.00"  /></h:outputText>

                                                                                    <f:facet name="footer">

                                                                                              <h:outputText value="#{record.totalHotels}"><f:convertNumber   pattern="$####.00"  /></h:outputText>

                                                                                    </f:facet>

                                                                          </rich:column>

                                                                          <rich:column>

                                                                                    <f:facet name="header">transport</f:facet>

                                                                                    <h:outputText value="#{expense.transport}"><f:convertNumber   pattern="$####.00"  /></h:outputText>

                                                                                    <f:facet name="footer">

                                                                                              <h:outputText value="#{record.totalTransport}"><f:convertNumber   pattern="$####.00"  /></h:outputText>

                                                                                    </f:facet>

                                                                          </rich:column>

                                                                          <rich:column>

                                                                                    <rich:spacer></rich:spacer>

                                                                                    <f:facet name="footer">

                                                                                              <h:outputText value="#{record.total}"><f:convertNumber   pattern="$####.00"    /></h:outputText>

                                                                                    </f:facet>

                                                                          </rich:column>

               

                                                                </rich:subTable>

               

                                                                <f:facet name="footer">

               

                                                                          <rich:columnGroup>

                                                                                    <rich:column>Totals</rich:column>

                                                                                    <rich:column>

                                                                                              <h:outputText value="#{report.expReport.totalMeals}"><f:convertNumber   pattern="$####.00"  /></h:outputText>

                                                                                    </rich:column>

                                                                                    <rich:column>

                                                                                              <h:outputText value="#{report.expReport.totalHotels}"><f:convertNumber   pattern="$####.00"  /></h:outputText>

                                                                                    </rich:column>

                                                                                    <rich:column>

                                                                                              <h:outputText value="#{report.expReport.totalTransport}"><f:convertNumber   pattern="$####.00"  /></h:outputText>

                                                                                    </rich:column>

                                                                                    <rich:column>

                                                                                              <h:outputText value="#{report.expReport.grandTotal}"><f:convertNumber   pattern="$####.00"  /></h:outputText>

                                                                                    </rich:column>

                                                                          </rich:columnGroup>

                                                                </f:facet>

               

                                                      </rich:dataTable>

               

               

              </ui:composition>

               

              getting:

              stable.png

              • 4. rich:dataTable how to print column headers multiple times
                cavinator

                Thank you Ilya,  but you missed understood me.  I want to reprint the headings from the rich:dataTable.  Assumed the headings in your rich:dataTable is not "Meals", "Hotels", and "Transport". but one column call "Location".  I want to print that heading "Location" above "San Jose" and right ablove "Seattle".  Everything else keep the same (ie. the rich:subtable still have the heading "day", "meals", "hotels" and "transport").

                 

                Thank you,

                 

                Cavin