5 Replies Latest reply on Nov 6, 2008 3:37 PM by Alexander Seitz

    Initial sort priority dataTable

    Yannick Bovy Newbie

      Hello,

      My goal is to initially sort a dataTable by the first column when the page is first loaded.

      I tried with:
      <rich:dataTable id="personsTable" value="#{persons}" var="person" sortPriority="primaryColumn,lastNameColumn" rendered="#{!empty persons}">

      and setting the column ids with

      <rich:column id="primaryColumn" sortBy="#{person.primary}">

      but this results in:
      Cannot convert primaryColumn,lastNameColumn of type class java.lang.String to interface java.util.Collection

      I couldn't find any proper examples on this topic, so I thought maybe one of you could help me out.

        • 1. Re: Initial sort priority dataTable
          Ilya Shaikovsky Master

          you should:

          1) define initial sortOrder on the columns which should be sorted.
          2) sortPriority - should be defined with EL binding to some collection that contains list of ids

          • 2. Re: Initial sort priority dataTable
            Yannick Bovy Newbie

            Thanks for your great help!
            Much kudos ;)

            • 3. Re: Initial sort priority dataTable
              Alexander Seitz Newbie

               

              "ilya_shaikovsky" wrote:
              you should:

              1) define initial sortOrder on the columns which should be sorted.
              2) sortPriority - should be defined with EL binding to some collection that contains list of ids


              Hi,

              I have a further question regarding this topic: I have accomplished the two steps Ilya stated above. Now, when loading the page, the columns of my rich:dataTable are sorted correctly.
              What I want now is to initially load the first row (which is a person object) in the same request. I know how to get the object in the first row of that table (with binding in backing bean). The problem is, that this first object I get in my backing bean is the one _before_ the sorting of the table is done. Obviously the rows are sorted _after_ my backing-bean-action reading the table binding...

              Any suggestions how to do that?

              Thanks!

              bRACHiE

              • 4. Re: Initial sort priority dataTable
                Ilya Shaikovsky Master

                 

                What I want now is to initially load the first row (which is a person object) in the same request.


                Sorry but we are really confused with your description..

                Could you please get us more detailed use-case explanation?

                • 5. Re: Initial sort priority dataTable
                  Alexander Seitz Newbie

                  Hi,

                  sorry for the confusion.

                  My page contains 2 areas (left and right) on the left there is the initially sorted datatable. On the right side you see the details of the clicked row in the table (person table and person details).

                  Now when the user opens this page, I want to initially load the first person from the (sorted) table on the right side.

                  My problem is that the sorting seems to be done at rendering time of the table and so I have no access in my backing bean, wich is invoked in the phase before...

                  I hope this explanation makes my problem more clear.