0 Replies Latest reply on May 5, 2011 9:33 AM by mano.swerts

    Prevent sorting when rerendering extendedDataTable cell

    mano.swerts

      Hi,

       

      We have a RichFaces 3.3.3 application which uses the rich:extendedDataTable component. We use the ajaxKeys property to make sure that only the necessary row is rerendered. In one of the columns, we have the following code:

       

       

      {code:xhtml}

      <rich:column sortBy="#{unreadDocumentUserAssignment.onHold}">

      <a:outputPanel id="onHoldPanel">

        <h:panelGroup rendered="#{unreadDocumentsBean.assigneeCurrentUser}">

          <a:commandLink value="On hold" rendered="#{unreadDocumentUserAssignment.onHold}" action="#{unreadDocumentsBean.unsetDocumentOnHold}" reRender="onHoldPanel">

            <a:actionparam name="selectedUserAssignmentId" assignTo="#{unreadDocumentsBean.selectedUserAssignmentId}" value="#{unreadDocumentUserAssignment.userAssignmentId}" />

            <a:actionparam name="selectedRowIndex" assignTo="#{unreadDocumentsBean.selectedRowIndex}" value="#{i}" />

          </a:commandLink>

       

          <a:commandLink value="Not on hold" rendered="#{not unreadDocumentUserAssignment.onHold}" action="#{unreadDocumentsBean.setDocumentOnHold}" reRender="onHoldPanel">

            <a:actionparam name="selectedUserAssignmentId" assignTo="#{unreadDocumentsBean.selectedUserAssignmentId}" value="#{unreadDocumentUserAssignment.userAssignmentId}" />

            <a:actionparam name="selectedRowIndex" assignTo="#{unreadDocumentsBean.selectedRowIndex}" value="#{i}" />

          </a:commandLink>

        </h:panelGroup>

      </a:outputPanel>

      </rich:column>


      {code}

       

      When the visible command link is clicked, the relevant user assignment is updated and the outputPanel is rerendered. We search for the user assignment using the id passed using the actionparam component and we update the ajaxKeys property with the "i" value, which is the rowKeyVar.

       

      A problem occurs when people sort by the "on hold" status first. When a user clicks the link to change the "on hold" status, sorting kicks in again. The rows reorder, so the wrong cell will be rerendered. The change in the on hold status is not reflected in the table untill we do a complete page refresh. Even worse, the user does not see the shift of the rows, because only 1 cell from 1 row is rerendered. The user will then perform actions on a row which represents another user assignment than the UI implies.

       

      We can solve this by rerendering the whole datatable, but in our opinion the jumping and shifting of the rows is very confusing for the users. When they have 40 user assignments and they sort by "on hold" and then change the "on hold" status for 1 particular assignment, then it is possible that the assigment jumps from e.g. row 3 to row 30. The user then needs to search for the particular user assigment again.

       

      For example OS X Mail sorts its tables on rendering. Not on rerender to prevent these confusing shifts of rows. We thought that RichFaces supported this as well by only rerendering 1 cell from 1 row to prevent the sorting from kicking and preserving the row order untill the next full refresh or the next manual sort using the column headers.

       

      Isn't this possible in anyway? According the ajaxKeys documentation, it should fully support rerendering of 1 cell for 1 row, but this is not the case because when sorting kicks in, rows will not be represented correctly on the UI which causes wrong data manipulation.

       

      Any thoughts, suggestions or fixes will be highly appreciated.

       

      Kind regards,

       

      Mano