6 Replies Latest reply on Feb 12, 2014 7:23 AM by vincent_deelen

    Interactive report check box triggering an dynamic action

    Eva E

      Hi,

       

      My interactive report is built based on the following query

       

      SELECT ID_OPERACION, NOMBRE_CLIENTE, TOTAL_PAGAR, APEX_ITEM.CHECKBOX(1,O.ID_OPERACION, 'onclick="f_UpdateCollection(this)"',a.c001) "Seleccionar"

      FROM OPERACIONES O, apex_collections a

      WHERE a.c001 (+)= O.ID_OPERACION

      and a.collection_name (+)= 'OPE_COLLECTION'


      I'm using a collection because I don't want to lose the selected checks caused by the pagination.


      I'm want to add a dynamic action that each time that a checkbox is selected, an item (P5_TOTAL_SELECCIONADO) sums the column TOTAL_PAGAR of all the selected check boxes, and that each time that a checkbox is deselected the item Total_seleccionado substracts the selected value.


      How can i do that?

        • 1. Re: Interactive report check box triggering an dynamic action
          vincent_deelen

          Hi Eva,

           

          Try a dynamic action, on click of jquery selector 'input[type="checkbox"]'. Add a condition of type javascript, condition:

          $(this.triggeringElement).prop('checked')

           

          Create a true action, type javascript:

          var total = $(this.triggeringElement).closest('td[headers="TOTAL_PAGAR"]').text()

          var total = $v('P5_TOTAL_SELECCIONADO') + total

          $s('P5_TOTAL_SELECCIONADO',total)

           

          and a false action, type javascript:

          var total = $(this.triggeringElement).closest('td[headers="TOTAL_PAGAR"]').text()

          var total = $v('P5_TOTAL_SELECCIONADO') - total

          $s('P5_TOTAL_SELECCIONADO',total)

           

          Regards,

          Vincent

          • 2. Re: Interactive report check box triggering an dynamic action
            Eva E

            I don't know if I'm doing it correctly, I did what you said but I don't get any value.

             

            I had created the app in my apex.oracle.com workspace.

             

            The workspace is cositaslindas_2, the user is developer and the password is Abc1234*

             

            The application is

            IRCHECKBOX

            78511

             

            Please check what I am doing wrong.

            • 3. Re: Interactive report check box triggering an dynamic action
              vincent_deelen

              Hi Eva,

               

              Please check your application again and see if this is what you were thinking of.

              I made a few changes. First of, here you were talking about P5_... items, in your apex.oracle workspace, the page number is 1, so I changed the P5_.. items to P1_...

              Then you left the fire on page laod checkboxes on, but you don't want t the function to start evaluating on page load.

               

              There were also some mistakes in the javascript I suggested. The selector for VALOR_PAGAR wasn't correct, I slightly changed that. Also all text values selected are strings and in javascript adding strings will just concatonate them. I made string to number conversion for you, also taking in account that null values (P1_TOTAL_SELECCIONADO on page load is null) can't be cast to number.

              The result is:

               

              var VALOR_PAGAR        = $(this.triggeringElement).closest('tr').find('td[headers="VALOR_PAGAR"]').text()

              var TOTAL_SELECCIONADO = $v('P1_TOTAL_SELECCIONADO')

               

              VALOR_PAGAR = (isNaN(VALOR_PAGAR = parseInt(VALOR_PAGAR)) ? 0 : VALOR_PAGAR)

              TOTAL_SELECCIONADO = ( isNaN(TOTAL_SELECCIONADO = parseInt(TOTAL_SELECCIONADO)) ? 0 : TOTAL_SELECCIONADO)

               

              var total              = VALOR_PAGAR + TOTAL_SELECCIONADO        

              $s('P1_TOTAL_SELECCIONADO',total)

               

              This is the code for adding checked checkboxes, the false action is the same except for total, which is:

              var total              = VALOR_PAGAR - TOTAL_SELECCIONADO        

               

              Regards,

              Vincent

              • 4. Re: Interactive report check box triggering an dynamic action
                Eva E

                You are right,

                 

                Thanks a lot

                • 5. Re: Interactive report check box triggering an dynamic action
                  Eva E

                  Hello

                   

                  I got an issue with this, if I apply filters or use some code in order to not lose the selected rows, or change of page the dynamic action lose the effect. I need to filter some ids and selected them, and later select another and that the total sums all all of them.

                   

                  Please your help

                  • 6. Re: Interactive report check box triggering an dynamic action
                    vincent_deelen

                    Hi Eva,

                    Make sure the event scope of the dynamic action is set to "Dynamic", rather than "Static"

                     

                    Regards,

                    Vincent

                    http://vincentdeelen.blogspot.com