1 Reply Latest reply on Jan 18, 2012 3:20 AM by Flavio Palumbo

    datatable column sorting doesn't work

    Flavio Palumbo Newbie

      Hi all,

       

      I'm trying to implement sort in a extendedDataTable column. I've seen example and looked to reference guide and code seems fine to me. Anyway when I click on the column header I can see (in debug mode) the bean making the right steps but view doesn't change.

      Can anybody help me ?

      I run with rf 4.0 on tomcat.

      Flavio

       

       

                          <rich:column id="a1id_col" width="40px" styleClass="text-to-right"

                                       sortBy="#{item.a1id}" sortOrder="#{eSBank.sortOrder4Id}">

                              <f:facet name="header">

                                  <a4j:commandLink value="#{mess.labelBankId}" render="ESBankTable"

                                                   action="#{eSBank.sortById}" />

                              </f:facet>

                              <h:outputText value="#{item.a1id}" id="a1id_fld"/>

                          </rich:column>

       

       

      public SortOrder getSortOrder4Id() {

              return getSortOrder4Column("a1id");

          }

       

      public void setSortOrder4Id(SortOrder inSo) {

              setSortOrder4Column("a1id", inSo);

          }

       

      public void sortById() {

              sort4Column("a1id");

          }

       

       

          String sortMode = "single";

          HashMap<String, ESSortOrderObj> hmSortOrder;

       

          public SortOrder getSortOrder4Column(String inColName) {

              if (hmSortOrder != null) {

                  if (hmSortOrder.get(inColName) != null) {

                      hmSortOrder.get(inColName).getSortOrder();

                  }

              }

              return SortOrder.unsorted;

          }

       

          public void setSortOrder4Column(String inColName, SortOrder inSo) {

              if (hmSortOrder != null) {

                  if (hmSortOrder.get(inColName) != null) {

                      hmSortOrder.get(inColName).setSortOrder(inSo);

                  }

              }

          }

       

          public void sort4Column(String inColName) {

              if (hmSortOrder != null) {

                  if (hmSortOrder.get(inColName) != null) {

                      Set set = hmSortOrder.entrySet();

                      Iterator it = set.iterator();

                      while (it.hasNext()) {

                          Map.Entry me = (Map.Entry) it.next();

                          if (!me.getKey().equals(inColName)) {

                              ((ESSortOrderObj) me.getValue()).resetSortOrder();

                          }

                      }

                      hmSortOrder.get(inColName).switchSortOrder();

                  }

              }

          }

       

          public class ESSortOrderObj {

       

              private SortOrder sortOrder = SortOrder.unsorted;

       

              public SortOrder getSortOrder() {

                  return sortOrder;

              }

       

              public void resetSortOrder() {

                  sortOrder = SortOrder.unsorted;

              }

       

              public void setSortOrder(SortOrder inSortOrder) {

                  this.sortOrder = inSortOrder;

              }

       

              public void switchSortOrder() {

                  if (sortOrder.equals(SortOrder.ascending)) {

                      setSortOrder(SortOrder.descending);

                  } else {

                      setSortOrder(SortOrder.ascending);

                  }

              }

          }

      }