5 Replies Latest reply on Sep 30, 2009 12:10 PM by asupa

    Sorting with richfaces 3.3

      Hi,

      I have a dataTable running off of a list of objects coming from a backing bean. I have specified the sortBy value on rich:columns inside the datatable to be a long defined inside the above object.

      <rich:dataTable value="#{reportTableView.rowList}" var="row" width="0" height="0">
       <rich:columns value="#{reportTableView.columns}" var="column" index="ind" sortBy="#{row.cellList[ind].value}">
       <h:outputText value="#{row.cellList[ind].displayValue}"/>
       </rich:columns>
      </rich:dataTable>
      


      The sorting works perfectly with RichFaces version 3.2
      But if I switch to 3.3 it stops working.

      Do I need to change something to make sorting work with 3.3?

      Thnks

        • 1. Re: Sorting with richfaces 3.3

          Hi,

          We got the issue since 3.3.0. So to fire sorting feature please follow by these points:

          1. Add sortOrder attribute and bind it to property of column instance:

          .....
          List<Column> columns;
          
          class Column {
          org.richfaces.model.Ordering ordering;
          ......
          }


          2. Assign unique id for each column.

          In result page code should be like as:

          <rich:dataTable value="#{reportTableView.rowList}" var="row" width="0" height="0">
           <rich:columns id="t#{ind}" value="#{reportTableView.columns}" var="column" index="ind" sortBy="#{row.cellList[ind].value}" sortOrder="#{column.ordering}">
           <h:outputText value="#{row.cellList[ind].displayValue}"/>
           </rich:columns>
          </rich:dataTable>
          


          • 2. Re: Sorting with richfaces 3.3

            Thnx for the quick response, but I have a followup question.

            In my implementation, the list of columns and the values I am displaying inside the columns come from different objects.

            That is,

            reportTableView.columns
            is the list that I iterate to know how many columns my table has. But I get the actual values from
            row.cellList
            .

            So my question is, which of these should have the order defined on them?

            Is there some other way to make sorting work?
            Will this bug be fixed in the future?

            • 3. Re: Sorting with richfaces 3.3
              asupa

              With this approach sorting works only for a couple clicks...it stops sorting after that. What could be going wrong?

              • 4. Re: Sorting with richfaces 3.3
                ilya_shaikovsky

                asupa, sorry but let us see the description of your concrete problem (ideally with code snippets). Currently can't confirm this because as you could check at richfaces-demo there is no such problem.

                • 5. Re: Sorting with richfaces 3.3
                  asupa

                  ilya_shaikovsky, here is the code snippet. CrystalListBean has session scope. I have created

                  <rich:dataTable value="#{crystalListBean.dataCollection.dataRows}"
                   var="dataRow" id="crystalTable" rendered="#{crystalListBean.showCrystalList}">
                   ...............
                  
                   <rich:columns value="#{crystalListBean.dataCollection.columns}"
                   var="column" index="ind" id="${idg.nextid}"
                   sortBy="#{dataRow.dataColumns[ind].value}"
                   sortOrder="#{column.ordering}">
                  
                   .............
                  
                   </rich:columns>
                  </rich:dataTable>
                  
                  


                  Here is the ordering field that i created in the column object

                  
                  
                  import org.richfaces.model.Ordering;
                  
                   .......................
                  
                   private Ordering ordering;
                  
                   public Ordering getOrdering() {
                   return ordering;
                   }