1 Reply Latest reply on Apr 25, 2010 2:38 PM by kbhattac.mailto.kaushik.gmail.com

    Preserve previously selected row on rich:extendedDatatable after sort

    kbhattac.mailto.kaushik.gmail.com

      Hi,


      I'm using a rich:extendedDataTable with sortable rich:column(s). If a row is selected and after that the table is sorted by a column, the row with the same row index remains selected, after the sort (instead of the previously selected row), which is wrong as the result set is now re-shuffled. Is this a bug of richfaces 3.3.1? Here is the used code snippet:




      <rich:extendedDataTable width="428px" id="puvTable" border="0" rows="0" var="obj" value="#{allobjs}" 
                                   style="border-bottom: 2px #FFF solid;table-layout:fixed;" height="340px"
                                   selection="#{tableWithFiltering.selection}" binding="#{tableWithFiltering.table}" 
                                   cellpadding="0" cellspacing="0" selectionMode="single" selectedClass="objSelected" noDataLabel="Geen data"
                                   onkeydown="jQuery('.content *:input[type!=hidden]:first').attr('maxlength',5);">
                                                      
              <a4j:support event="onselectionchange" action="#{tableWithFiltering.select(OBJ_SELECT_EVENT)}" 
                      ajaxSingle="true" reRender="objs" oncomplete="reRenderBorder();"/>
      
              <a4j:support event="onkeyup" action="#{tableWithFiltering.filter(OBJ_SELECT_EVENT)}" 
                      ajaxSingle="true" reRender="objs" oncomplete="reRenderBorder();"/>
      
              <rich:column id="id"
                           filterBy="#{obj.ID}" 
                           filterEvent="onkeyup"
                           headerClass="text-column-indent"
                           styleClass="text-column-indent" 
                           sortBy="#{obj.ID}" 
                           sortable="true" 
                                   width="80" 
                                   sortIconAscending="#{facesContext.externalContext.requestContextPath}/images/filterdown.gif"
                                   sortIconDescending="#{facesContext.externalContext.requestContextPath}/images/filterup.gif"
                                   sortIcon="#{facesContext.externalContext.requestContextPath}/images/filternone.gif">
                 <f:facet name="header">
                              <h:outputText styleClass="headerText" value="#{messages['beheren.obj.filter.id']}"/>
                      </f:facet>
                      <h:outputText value="#{obj.ID}"/>
              </rich:column>
      
              ...
      </rich:extendedDataTable>



        • 1. Re: Preserve previously selected row on rich:extendedDatatable after sort
          kbhattac.mailto.kaushik.gmail.com

          Here's the Seam component:





          @Scope(EVENT)
          @Name("tableWithFiltering")
          public class FilterableTableSelectionSupport {
          
              protected Object selectedEntity;
              private HtmlExtendedDataTable table;
              private SimpleSelection selection;
          
              public void select(String event) {
          
                  if (selection != null) {
                      log.debug("in tablerow select(event)");
                      doSelect();
                      String eventName = isEmpty(event) ? "tableRow.selected." + selectedEntity.getClass().getSimpleName() : event;
                      Events.instance().raiseEvent(eventName, selectedEntity);
                  }
              }
              
              public HtmlExtendedDataTable getTable() {
                  return table;
              }
          
              public void setTable(HtmlExtendedDataTable table) {
                  this.table = table;
              }
          
              public SimpleSelection getSelection() {
                  return selection;
              }
          
              public void setSelection(SimpleSelection selection) {
                  this.selection = selection;
              }
          }