4 Replies Latest reply on Mar 16, 2007 12:51 PM by alexsmirnov

    rich:dataTable and sortable Columns

    damianharvey

      Hi,

      I see that a request has been made for Sortable DataTable columns in the JIRA for release 3.1 (RF-6). Is there any workaround to allow for sortable columns in the current release or should I use a Tomahawk table?

      Thanks,

      Damian

        • 1. Re: rich:dataTable and sortable Columns

          I always wonder what is "sortable column support"? Like for example you have a table, that display some data that come from some query from database. How you suppose to sort it? On client? In memory on server? On database? How you will tell to the database what column need to be sorted?

          My point is that "sortable column" cannot be implemented in generic way. All mentioned usecases may take place and it is completely different. All we can do is to provide "plumbing" that allows to react to some user actions (like click on column header) and do whatever application need to do with it.

          However, I guess we owe some sample that show how rich:dataTable may be used in "sortable column" usecase.

          • 2. Re: rich:dataTable and sortable Columns

            A workaround is using an actionlistener to get the column id, sort the data (by using e.g. a specialized comperator) and than rerender the list. It works fine.

            • 3. Re: rich:dataTable and sortable Columns
              amitev

              Maybe something like tomahawk's solution? They have name attribute on the column component and that name is passed to value expression and a bollean property for the type of sorting (ascending/descending).

              • 4. Re: rich:dataTable and sortable Columns
                alexsmirnov

                rich:datatable component is have hoock to easy create sortable data models. In differense with JSF UIData component, rows iterations is moved to extended data model with visitor pattern. Iteration order can be changed in model, even at HQL/SQL queries or other application-specific methods.