10 Replies Latest reply on May 11, 2009 1:30 AM by Cencil Chow

    ScrollableDataTable select after sort

    Cencil Chow Newbie

      Hi,

      I have a master-detail page using ScrollableDataTable, it works fine and with selection enabled. But if I sort by clicking column header, then the selected object is not the row data and so it display incorrect selected item.

      Here is my code:

      xhtml

      <rich:scrollableDataTable id="shSdt" rowKeyVar="rkv"
      value="#{svsShareHolderMaintDetail_backing.shareHolders}"
      binding="#{svsShareHolderMaintDetail_backing.shSdt}"
      var="item"
      selection="#{svsShareHolderMaintDetail_backing.selection}"
      rows="0"
      sortMode="single"
      sortOrder="#{svsShareHolderMaintDetail_backing.sortOrder}"
      width="250px" height="160px"
      rowClasses="sdt-odd-row,sdt-even-row">
      <a4j:support event="onselectionchange" action="#{svsShareHolderMaintDetail_backing.takeSelection}"
      reRender="detail"/>
      <rich:column id="name" width="220px" sortBy="#{item.name}">
      <f:facet name="header">
      <h:outputText value="Share Holders" />
      </f:facet>
      <h:outputText value="#{item.name}"/>
      </rich:column>
      </rich:scrollableDataTable>


      bean

      public SimpleSelection getSelection() {
      return selection;
      }

      public void setSelection(SimpleSelection selection) {
      this.selection = selection;
      }

      public String takeSelection() {
      Iterator i = getSelection().getKeys();
      while (i.hasNext()) {
      Object key = i.next();
      shSdt.setRowKey(key);
      if (shSdt.isRowAvailable()) {
      shareHolder = (ShareHolder) shSdt.getRowData();
      }
      }

      return null;
      }



      Thanks!!