2 Replies Latest reply on Jun 19, 2008 4:41 PM by David Greenberg

    sortBy with breakBefore

    David Greenberg Newbie

      Hi,

      I am trying to create a table whose rows are doubled-up. I also want it to be sortable. This is an example of the HTML for the structure of the table that I want:

      <table ...>
       <thead>
       <tr>
       <td>column A</td>
       <td>column B</td>
       <td>column C</td>
       </tr>
       <tr>
       <td>column D</td>
       <td>column E</td>
       <td>column F</td>
       </tr>
       </thead>
       <tbody>
       <tr>
       <td>record 1 value A</td>
       <td>record 1 value B</td>
       <td>record 1 value C</td>
       </tr>
       <tr>
       <td>record 1 value D</td>
       <td>record 1 value E</td>
       <td>record 1 value F</td>
       </tr>
       <tr>
       <td>record 2 value A</td>
       <td>record 2 value B</td>
       <td>record 2 value C</td>
       </tr>
       <tr>
       <td>record 2 value D</td>
       <td>record 2 value E</td>
       <td>record 2 value F</td>
       </tr>
       </tbody>
      </table>
      


      The following comes close, but does not quite work:

      <rich:dataTable ...>
       <rich:column sortBy="#{mybean.a}">
       <f:facet name="header">
       <h:outputText value="column A" />
       </f:facet>
       <h:outputText value="#{mybean.a}" />
       </rich:column>
       <rich:column sortBy="#{mybean.b}">
       <f:facet name="header">
       <h:outputText value="column B" />
       </f:facet>
       <h:outputText value="#{mybean.b}" />
       </rich:column>
       <rich:column sortBy="#{mybean.c}">
       <f:facet name="header">
       <h:outputText value="column C" />
       </f:facet>
       <h:outputText value="#{mybean.c}" />
       </rich:column>
       <rich:column breakBefore="true" sortBy="#{mybean.d}">
       <f:facet name="header">
       <h:outputText value="column D" />
       </f:facet>
       <h:outputText value="#{mybean.d}" />
       </rich:column>
       <rich:column sortBy="#{mybean.e}">
       <f:facet name="header">
       <h:outputText value="column E" />
       </f:facet>
       <h:outputText value="#{mybean.e}" />
       </rich:column>
       <rich:column sortBy="#{mybean.f}">
       <f:facet name="header">
       <h:outputText value="column F" />
       </f:facet>
       <h:outputText value="#{mybean.f}" />
       </rich:column>
      </rich:dataTable>
      


      This produces a sortable table with doubled-up rows, but the headers are all on one line, similar to the following:

      <table ...>
       <thead>
       <tr>
       <td>column A</td>
       <td>column B</td>
       <td>column C</td>
       <td>column D</td>
       <td>column E</td>
       <td>column F</td>
       </tr>
       </thead>
       <tbody>
       <tr>
       <td>record 1 value A</td>
       <td>record 1 value B</td>
       <td>record 1 value C</td>
       </tr>
       <tr>
       <td>record 1 value D</td>
       <td>record 1 value E</td>
       <td>record 1 value F</td>
       </tr>
       <tr>
       <td>record 2 value A</td>
       <td>record 2 value B</td>
       <td>record 2 value C</td>
       </tr>
       <tr>
       <td>record 2 value D</td>
       <td>record 2 value E</td>
       <td>record 2 value F</td>
       </tr>
       </tbody>
      </table>
      


      I have tried the following with no luck:

      <rich:dataTable ...>
       <f:facet name="header">
       <rich:columnGroup>
       <rich:column sortBy="#{mybean.a}">
       <h:outputText value="column A" />
       </rich:column>
       <rich:column sortBy="#{mybean.b}">
       <h:outputText value="column B" />
       </rich:column>
       <rich:column sortBy="#{mybean.c}">
       <h:outputText value="column C" />
       </rich:column>
       <rich:column breakBefore="true" sortBy="#{mybean.d}">
       <h:outputText value="column D" />
       </rich:column>
       <rich:column sortBy="#{mybean.e}">
       <h:outputText value="column E" />
       </rich:column>
       <rich:column sortBy="#{mybean.f}">
       <h:outputText value="column F" />
       </rich:column>
       </rich:columnGroup>
       </f:facet>
       <rich:column sortBy="#{mybean.a}">
       <h:outputText value="#{mybean.a}" />
       </rich:column>
       <rich:column sortBy="#{mybean.b}">
       <h:outputText value="#{mybean.b}" />
       </rich:column>
       <rich:column sortBy="#{mybean.c}">
       <h:outputText value="#{mybean.c}" />
       </rich:column>
       <rich:column breakBefore="true" sortBy="#{mybean.d}">
       <h:outputText value="#{mybean.d}" />
       </rich:column>
       <rich:column sortBy="#{mybean.e}">
       <h:outputText value="#{mybean.e}" />
       </rich:column>
       <rich:column sortBy="#{mybean.f}">
       <h:outputText value="#{mybean.f}" />
       </rich:column>
      </rich:dataTable>
      


      This puts the columns in two rows correctly, but they are no longer sortable.

      Any help is greatly appreciated.

      Thank you,
      David


        • 1. Re: sortBy with breakBefore
          David Greenberg Newbie

          I have also tried adding columns to the header facets like this:

          <rich:column sortBy="#{mybean.a}">
           <f:facet name="header">
           <rich:column>
           <h:outputText value="column A" />
           </rich:column>
           <h:outputText value="#{mybean.a}" />
           </f:facet>
          </rich:column>
          


          I have tried this with every combination of breakBefore, and succeeded only in shifting the data to the right side of the table instead of the left.

          This is driving me crazy. I'm sure someone else has wanted to do this before. Does anyone have any advise?

          • 2. Re: sortBy with breakBefore
            David Greenberg Newbie

            Another note:
            It appears that I am not the first to have this problem:
            http://www.jboss.com/index.html?module=bb&op=viewtopic&t=132863

            It also appears that there is something of a fix in 3.2.1 (http://jira.jboss.com/jira/browse/RF-2920). I am using 3.2.0.SR1 because I also use MyFaces 1.2.3. (http://www.jboss.com/index.html?module=bb&op=viewtopic&t=136540)

            So, now I have the following with 3.2.1.GA:

            <rich:dataTable ...>
             <f:facet name="header">
             <rich:columnGroup>
             <rich:column>
             <h:outputText value="column A" />
             </rich:column>
             <rich:column>
             <h:outputText value="column B" />
             </rich:column>
             <rich:column>
             <h:outputText value="column C" />
             </rich:column>
             <rich:column breakBefore="true">
             <h:outputText value="column D" />
             </rich:column>
             <rich:column>
             <h:outputText value="column E" />
             </rich:column>
             <rich:column>
             <h:outputText value="column F" />
             </rich:column>
             </rich:columnGroup>
             </f:facet>
             <rich:column sortBy="#{mybean.a}">
             <h:outputText value="#{mybean.a}" />
             </rich:column>
             <rich:column sortBy="#{mybean.b}">
             <h:outputText value="#{mybean.b}" />
             </rich:column>
             <rich:column sortBy="#{mybean.c}">
             <h:outputText value="#{mybean.c}" />
             </rich:column>
             <rich:column sortBy="#{mybean.d}">
             <h:outputText value="#{mybean.d}" />
             </rich:column>
             <rich:column sortBy="#{mybean.e}">
             <h:outputText value="#{mybean.e}" />
             </rich:column>
             <rich:column sortBy="#{mybean.f}">
             <h:outputText value="#{mybean.f}" />
             </rich:column>
            </rich:dataTable>
            


            Still no luck.