12 Replies Latest reply on May 11, 2009 11:45 AM by Nick Thomson

    ajaxKeys with sortable dataTable problem

    Nick Thomson Newbie

      I'm using ajaxKeys on a dataTable to control which rows are reRendered after an update. I have it working fine with a standard table and even with pagination using the datascroller.

      However, when I use the sorting capabilities of the dataTable, the rows do not highlight properly. I'm guessing this is because they are in a different order to the list I store the data in and therefor the wrong indexes are being returned.

      My data table in my test app looks like this:

       <rich:dataTable id="testDataTable" value="#{testBean.data}" var="data" ajaxKeys="#{testBean.ajaxKeys}" sortMode="single">
       <rich:column sortBy="#{data.id}" sortOrder="#{testBean.orderID}" id="pid" style="#{data.viewing ? 'background: red' : '' }">
       <f:facet name="header">
       <h:outputText value="ID"/>
       <a4j:commandLink style="display: block; width: 100%;" action="#{testBean.SelectView(data)}" value="#{data.id}" reRender="pid,param1"/>
       <rich:column sortBy="#{data.testParam1}" sortOrder="#{testBean.orderParam1}" id="param1" style="#{data.viewing ? 'background: red' : '' }">
       <f:facet name="header">
       <h:outputText value="Param 1"/>
       <a4j:commandLink style="display: block; width: 100%;" action="#{testBean.SelectView(data)}" value="#{data.testParam1}" reRender="pid,param1"/>

      And the appropriate parts of the backing bean:

      private List<TestData> data = new ArrayList<TestData>();
      private TestData selectedItem = null;
      private HashSet<Integer> ajaxKeys = new HashSet<Integer>();
      public void SelectView(TestData data) {
       this.selectedItem = data;
      public TestData getSelectedItem() {
       return selectedItem;
      public void setSelectedItem(TestData selectedItem) {
       this.selectedItem = selectedItem;
      public Set<Integer> getAjaxKeys() {
       return this.ajaxKeys;

      Anyone have any suggestion how to fix this?