4 Replies Latest reply on Oct 16, 2009 4:20 AM by Gianfranco Zola

    DataTable RowKeyVar problem

    Gianfranco Zola Newbie

      Hi!

      I'm facing a small problem. Due to performance reasons I've created an own datamodel for the rich:datatable component. In this datamodel (wich extends ModifiableModel) I check wether the sorting or filtering has been changed since last rendering, or not. If not I use the cached data to display the records (wich incredibly increases paging perfomance with datascroller for huge datasets!) and if only the sorting changed, I resort the cached data without retrieving the whole dataset, refiltering and then sorting as implemented in ExtendedDataModel.

      Now the problem is that if I define a rowkeyvar in the DataTable to display row numbers, the row numbers are mixed upon filtering or sorting.

      Like:

      Datatable using normal data model:

      rowkeyvar data
      1. something
      2. anything
      


      Now this sorted by data:
      rowkeyvar data
      1. anything
      2. something
      


      With my datamodel:
      rowkeyvar data
      1. something
      2. anything
      


      Now this sorted by data:
      rowkeyvar data
      2. anything
      1. something
      


      As you see the rowkeyvar was maintained and "mixed". This also happens with filtering.

      I know the reason: the original data list from the dataprovider is untouched and the rowkeys are maintained for the original list.

      My question is how to implement a "rownum" variable similar to rowkeyvar where I could display always the correct row number from 1 to rowcount?

      I examined the UIDataAdaptor code a lot to implement a RowNum variable similar to RowKeyVar, but no idea till now how to reset it and increment it by row to row.

      Thank you in advance!

      Regards,

      Gizola

      PS: oh, yes, Richfaces 3.3.0 GA I'm using.