0 Replies Latest reply on Nov 22, 2013 12:58 PM by jmanko

    List for scrollableDataTable, and client-side sorting

    jmanko

      I have a List that in my backing bean that I use for a Richfaces scrollableDataTable.  I'm running into a problem when doing client-side sort a table:

       

       

      <r:scrollableDataTable id="remarkTable" value="#{remarkController.remarks}" selection="#{remarkController.selection}"

            sortMode="single" selectionMode="single" var= "dataItem" rows="10"

            height="273px" width = "916px" rowClasses="list-row-odd, list-row-even" selectedClass="selectedRow">

            <a:support id="remarkSelect" event="onRowClick" action="#{remarkController.reviewRemark}" reRender="remarkDetails"/>



      After sorting the table client-side, clicking on a row loads the record which was at that position prior to sorting.  Here is how I find the activated remark:

       

      public void reviewRemark() {

              // selection is used on the component to store the selected

              // row(s), of type org.richfaces.model.selection.Selection

              if (selection.size() > 0) { 

                  Remark remark = null;           

                  Iterator i = selection.getKeys();

                  while (i.hasNext()) {

                      remark = (Remark) remarks.get((Integer) i.next());               

                      break;

                  }

                  if (remark != null) {

                      this.setRemark(remark);

                  }

              } else {

                  resetRemark();

              }

      }

       

      If I understand how it is working, I believe that the row click is indexed and that index saved in the Selection collection.  My question: how can I use client-size sorting, with a List, yet still have a row selection that return a valid row to the Selection collection?