4 Replies Latest reply on Jan 12, 2018 5:47 PM by Soukaina IDRISSI

    How to keep checkbox checked in tabular form scrolling between pages

    Soukaina IDRISSI

      Hi everybody,

      1. I have created a Tabular Form that contain more than 20 rows.
      2. I implemented a row selector in the TF.
      3. I fixed the Layout Section , and specially Number Of Rows= 6

       

      My issue:

      When I select for example :

      - 2 rows (in the first list of 6rows) in Tabular form,

      - After that i click to Button Next in pagination, to get next list of products, and selecting the rest of products.

      - Finally when i click to button Back in pagination, what happen, the chechboxes no longer checked.

       

      You can see demonstration of problem, on apex.oracle.com with this credentials:

      Workspace: ws_formation

      Username: asoukaina

      Password: s@boulah123

       

      I used the Application 96915 - Calcul Bill, Page1 (96915:1)

       

      NB:

      APEX Version: 5.1

        • 1. Re: How to keep checkbox checked in tabular form scrolling between pages
          -Max-

          Hello Soukaina IDRISSI

           

          In order to do that, you will have to store the checked rows somewhere.

          What I usually do is save them in a collection.

           

          The general idea is to create a collection on page load.

          Depending on your use case, you might need to change your report's SQL query ton add the collection's values.

           

          Then what I usually do is add a class to the checkbox (using the apex_item.checkbox).

          Then you will need to create an on change DA on the above class (using jQuery selector).

          In that DA, I usually have two action. The first one (javascript action) retrieves the checkbox's value and save it in a page item, the second one (pl/sql action) will update the collection.

           

          Here is an example, you will need to adapt to your use case.

           

          Report SQL

          select APEX_ITEM.CHECKBOX2(1, e.empno, case when col.checkbox = 'Y' then 'CHECKED' end || 'class="empCheckbox" data-seq_id="' || col.seq_id || '" data-attr_number="1"') checkbox,
                 ....
            from emp e,
                 (select seq_id, c001 empno, C002 checkbox
                    from APEX_COLLECTIONS
                   where collection_name = 'your_collection_name') col
           where col.empno = e.empno
          

           

          JavaScript Action

          var $item   = $(this.triggeringElement),
              l_value = $item.val();
              
          apex.item('P10_SEQ_ID').setValue($item.data('seq_id'));
          apex.item('P10_ATTR_NUMBER').setValue($item.data('attr_number'));
          apex.item('P10_ATTR_VALUE').setValue(l_value);
          

           

          PL/SQL Action

          declare
              l_col_name varchar2(255) := 'your_collection_name';
          begin
              apex_collection.update_member_attribute(
                  p_collection_name => l_col_name,
                  p_seq             => to_number(:P10_SEQ_ID),
                  p_attr_number     => to_number(:P10_ATTR_NUMBER),
                  p_attr_value      => :P10_ATTR_VALUE);
          end;
          

           

          Regards

          Max

          • 2. Re: How to keep checkbox checked in tabular form scrolling between pages
            Soukaina IDRISSI

            Thank you Max for reply,

            I followed your solution, and i get empty Tabular Form.

             

            You can see what i did, on apex.oracle.com with this credentials:

             

            Workspace: ws_formation

            Username: asoukaina

            Password: s@boulah123

             

            I used the Application 96915 - Calcul Bill, Page1 (96915:1)

            • 3. Re: How to keep checkbox checked in tabular form scrolling between pages
              -Max-

              Hello Soukaina IDRISSI

               

              I had a look at your application.

               

              You were missing:

              • a process on page load to create the collectionb
              • the three items on the page (P1_SEQ_ID,P1_ATTR_NUMBER,P1_ATTR_VALUE)
              • make sure these items are set to protected = "No"
              • for the DA selector, you can use the class that you set for the checkbox

               

              You should have a look at the documentation of collections here

               

              Regards

              Max

              • 4. Re: How to keep checkbox checked in tabular form scrolling between pages
                Soukaina IDRISSI

                I did what you said, but i still have the issue.

                Can you do the traitement, if you want ,in the demo application, maybe I misunderstood what you told me, or I did a bad manipulation.

                 

                Thank you in advance .