7 Replies Latest reply on Apr 3, 2009 6:33 AM by tobi04

    rich:extendedDataTable - select all items

      Hi all

      I am using rich:extendedDataTable component with multi selection mode.

      I am looking for a possibility to "select all" items in the table with a new button or link?


      Best regards
      Tobi

        • 1. Re: rich:extendedDataTable - select all items
          ilya_shaikovsky

          You could use selection attribute to submit selection (the same as for scrollable sample).. so in the same way you could make all the items selected in some your action.

          • 2. Re: rich:extendedDataTable - select all items

            Hi Ilya,

            thanks for your reply.

            I implement your idea as you can see below.

            If no row is selected in the table the "select all" and "deselect all" buttons work fine.
            If I select one or more rows and click on the "deselect all" button then the rows still selected.

            What do I forget?

             <h:panelGrid id="mainPanel" style="table-layout: fixed;" columns="2" columnClasses="leftColumn, rightColumn">
            ...
             <a4j:commandButton value="select all"
             action="#{extendedDataTableBean.selectAll}"
             reRender="mainPanel" />
             <a4j:commandButton value="deselect all"
             action="#{extendedDataTableBean.selectAllNot}"
             reRender="mainPanel" />
            ...
             <rich:extendedDataTable id="demoTable"
             value="#{extendedDataTableBean.dataModel}" var="patient"
             style="margin: 0 auto;"
             rows="#{extendedDataTableControlBean.rowsNumber}"
             width="#{extendedDataTableControlBean.width}"
             height="#{extendedDataTableControlBean.height}"
             selectedClass="dataTableSelectedRow" footerClass="demo-footer"
             sortMode="#{extendedDataTableControlBean.sortMode}"
             selectionMode="#{extendedDataTableControlBean.selectionMode}"
             selection="#{extendedDataTableBean.selection}" rowKeyVar="rkvar"
             tableState="#{extendedDataTableBean.tableState}"
             >
            ...
             </h:panelGrid>
            
            
            
            public class ExtendedDataTableBB {
            ...
             private SimpleSelection selection = new SimpleSelection();
            ...
             public void selectAll() {
             selection.setSelectAll(true);
             }
            
             public void selectAllNot() {
             selection.setSelectAll(false);
             }
            
            


            • 3. Re: rich:extendedDataTable - select all items

              Hi all

              the problem still exists. Any ideas?

              Best regards
              Tobi

              • 4. Re: rich:extendedDataTable - select all items
                ilya_shaikovsky

                set the buttons ajaxSingle="true". selection itself submitted and so new one not considered.

                B.t.w. I will recheck the way we considered isSelectAll at encode if selection itself contains elements and update if some more problems appears.

                • 5. Re: rich:extendedDataTable - select all items
                  ilya_shaikovsky

                  b.t.w. setSelectAll(false) will not work as you await.. because it just tells that all rows are not selected. But selection items in list still actual and the list isn't empty.

                  But setSelectAll(true) should works fine at list with ajax Single.

                  • 6. Re: rich:extendedDataTable - select all items
                    ilya_shaikovsky

                    even ajaxSingle not nesessary. our simple implementation just not consider the all selected property if the selected items set not empty. You could clean the set in your action before setting select all or just fill the set with all items. and just clear this set for deselection.

                    • 7. Re: rich:extendedDataTable - select all items

                      Hi Ilya,

                      thanks for your reply.

                      Your tips (selection.clear()) were very helpful and now my solution works and looks like this:

                       <h:panelGrid id="mainPanel" style="table-layout: fixed;" columns="2" columnClasses="leftColumn, rightColumn">
                      ...
                       <a4j:commandButton value="select all"
                       action="#{extendedDataTableBean.selectAll}"
                       reRender="mainPanel" />
                       <a4j:commandButton value="deselect all"
                       action="#{extendedDataTableBean.selectAllNot}"
                       reRender="mainPanel" />
                      ...
                       <rich:extendedDataTable id="demoTable"
                       value="#{extendedDataTableBean.dataModel}" var="patient"
                       style="margin: 0 auto;"
                       rows="#{extendedDataTableControlBean.rowsNumber}"
                       width="#{extendedDataTableControlBean.width}"
                       height="#{extendedDataTableControlBean.height}"
                       selectedClass="dataTableSelectedRow" footerClass="demo-footer"
                       sortMode="#{extendedDataTableControlBean.sortMode}"
                       selectionMode="#{extendedDataTableControlBean.selectionMode}"
                       selection="#{extendedDataTableBean.selection}" rowKeyVar="rkvar"
                       tableState="#{extendedDataTableBean.tableState}"
                       >
                      ...
                       </h:panelGrid>
                      
                      
                      
                      public class ExtendedDataTableBB {
                      ...
                       private SimpleSelection selection = new SimpleSelection();
                      ...
                       public void selectAll() {
                       selection.clear();
                       selection.setSelectAll(true);
                       }
                      
                       public void selectAllNot() {
                       selection.clear();
                       selection.setSelectAll(false);
                       }
                      
                      



                      Best regards
                      Tobi