0 Replies Latest reply on Aug 4, 2011 8:11 AM by Carlos Alexandro Becker

    Rich:dataTable sort doesn't update managed bean List

    Carlos Alexandro Becker Newbie

      Hi all!

       

       

      In my application, I have a list of records. The user can select any record, updating a menu of options. The table shows that these records, it has paging.

      So the problem is that when I select a record, and sort the list (making the record I had selected before go to another page), I lose sight of the selected record.

      I wanted after ordering, have selected the correct page.

      Ok, so I created a method to this: Figure out which page should be selected, and update the pager.

      This method would work perfectly if the richfaces table also ordered the List from the managed, instead of ordering only the table on the client side.

      So is there any way (without a lot of workaround) I could update the List from the managed well?

       

      I'am using Richfaces 3.3.3 and JSF1.2.

       

      I'm tried to do a workaround, I've add a handler in the header of column (using jQuery), and get the header name using this code:

       

      var col = jQuery(event.target);

      var cabColuna = getTextColunaRecursive(col);

      onclickOrdenarTabela(cabColuna);

       

      getTextColunaRecursive function is something like that:

      function getTextColunaRecursive(col_)

      {

                if(col_.is('span'))

                {

                          return col_.text();

                }

                else

                {

                          var c = col_.find('.rich-table-sortable-header');

                          if(c.is('span'))

                          {

                                    return c.text();

                          }

                          else

                          {

                                    return getTextColunaRecursive(col_.parent());

                          }

                }

      }

       

      So, i've been able to set the column clicked on the managed bean, and sort it using commons collections. BUT, my sort was different from the sort of richfaces.

       

      What can I do about that? Is there any way to do it more simple?

       

      Thanks.

      Sorry my bad, bad english...

       

       

       

      thanks.