4 Replies Latest reply on Jun 3, 2008 6:59 PM by bostone

    rich:dataTable - multiple rows selection

    bostone

      Just curious if someone has done multiple row selection in rich:dataTable. And by that I don't mean retarded checkboxes in each row but rather Ctrl/clicking and highlighting multiple rows from the table. I can easily do multiple row selection on the client with something like jQuery table but how to detect selected rows in the action call? Any pointers/suggestions will be highly appreciated. And no, I don't want use scrollable datatable, that has more problems than benefits as far as my experience goes

        • 1. Re: rich:dataTable - multiple rows selection
          ilya_shaikovsky

          from this point rich:dataTable has no differences from standard h: one. So no solution out of the box.

          In order to implement selection you should:

          1) implement client side selection (for example with JQerry as you explained)
          2) But additionally with styles changing, call for example a4j:jsFunction - everytime you need to highlight the row. And in this ajax request - select/deselect the clicked row.

          • 2. Re: rich:dataTable - multiple rows selection
            bostone

            Thanks, Ilya, at least I know that I'm on my own :) Meanwhile I have a question in regard to checkbox in each row. I simply place <h:selectOneBoolean /> in the column: no binding, no value, no id. Then I select few boxes and submit the request. What puzzles me, I always get just one checkbox, when I traverse the table children. What I'm trying to avoid is to roundtrip to the server each time I select/unselect a box - I know I can do that and I've seen people doing it. What would be a good way to implement multiple row selection based on checkbox in the row with just a single submit?
            Thanks

            • 3. Re: rich:dataTable - multiple rows selection
              eicki

              Best (or at least one) way would be to value-bind the checkbox to a property of the item that represents the current row.

              • 4. Re: rich:dataTable - multiple rows selection
                bostone

                 

                "eicki" wrote:
                Best (or at least one) way would be to value-bind the checkbox to a property of the item that represents the current row.


                Aghm... that only helps if you let say double click on the single row to select. Plus I don't have a luxury of adding fields to my item - it's basically Hibernate generated POJO that maps to a certain table.

                One way is to have action assigned to the checkbox and maintain list of selected items on the server but it is retarded in my view since it's generating useless traffic.

                I dig into the issue that my submit always returns just one value for the checkbox and I found out two things:
                1. All the checkboxes are generated with same ID which sorta make sense if you are using single selection
                2. If you try to stick EL into id it is totally ignored, so for example <h:selectOneBoolean id="#{foo.id}" /> will fail since it will complain about empty ID

                When I'll figure it out I'll post my solution