1 Reply Latest reply on Oct 4, 2012 2:39 PM by vi_mahe_ka1

    How to get the selected row of a filtered extendedDataTable?

    sandro.braendli

      In my application (RichFaces 4.1) I have an extendedDataTable, in my backing bean I need to track the selected rows. This works fine as long as the table is not filtered.

       

      When the table is filtered and I select for instance the first row, I get the rowKey for the first row of the unfiltered table in the backing bean. How can I get the rowData of the selected row when my table is filtered?

       

      I use the following Code for my table:


       

      <rich:extendedDataTable id="freie"
          selectionMode="multipleKeyboardFree"
          selection="#{myBean.tableSelection}"
          ...
      <a4j:ajax execute="@this" event="selectionchange" 
                listener="#{myBean.tableSelection}"
                render="indicatorPanel" />
      

       

       

      UIExtendedDataTable dataTable= (UIExtendedDataTable) event.getComponent();
      Object originalKey= dataTable.getRowKey();
      _tableSelectedEntries.clear();
      for (Object selectionKey: _tableSelection) {
          dataTable.setRowKey(selectionKey);
          if (dataTable.isRowAvailable()) {
              _tableSelectedEntries.add((Entry) dataTable.getRowData());
          }
      }
      dataTable.setRowKey(originalKey);
      

       

      <rich:column sortBy="#{mitarbeiter.vorname}"
       filterValue="#{mitarbeiterFilterBean.firstNameFilter}"
       filterExpression="#{fn:containsIgnoreCase(mitarbeiter.vorname, mitarbeiterFilterBean.firstNameFilter)}">
      

       

      I think I am doing it the same way as it is done in the showcase (http://showcase.richfaces.org/richfaces/component-sample.jsf?demo=extendedDataTable&sample=exTableSelection&skin=blueSky).