10 Replies Latest reply on Oct 17, 2008 12:31 PM by ATD

    set Interactive Report in popup with start search value and submit

    Tobias Arnhold
      Hi,

      I want to start an pop up with an IR in it which gets an value in the search area and finally a submit/search actiion should update the report.
      onload="set_ir_search_val();"
      <script language="JavaScript" type="text/javascript">
      function set_ir_search_val() {
      var v_stop_js = document.getElementById('P105_STOP_JS');
      if (v_stop_js.value != 1) {
      var v_page = 'P' + '&P105_WHEREFROM.' + '_ID';
      var v_from = opener.document.getElementById(v_page);
      var v_to = document.getElementById('apexir_SEARCH');
      v_to.value = v_from.value;
      v_stop_js.value = 1;
      /*gReport.search('SEARCH'); -- that didn't work*/
      }
      }
      </script>
      Unfortunately the report update doesn't work automatically. Firebug means: gReport is undefined

      Any ideas?

      Thanks ahead,

      Tobias
        • 1. Re: set Interactive Report in popup with start search value and submit
          ATD
          Hi,

          In the page template that you're using for the popup, check to ensure that you have #HEAD# included (usually it's immediately after the TITLE tags - this provides the javascript files that handle this functionality, so it could be that it's missing?

          Andy
          • 2. Re: set Interactive Report in popup with start search value and submit
            Roel Hartman
            Hello Tobias

            Maybe you can use the standard parameters for IR's. If you add a IR_<column_name> to your report call.

            Otherwise can you upload an example to apex.oracle.com?

            Regards
            Roel
            • 3. Re: set Interactive Report in popup with start search value and submit
              Tobias Arnhold
              Hi Roel and Andy!

              The report itself works fine (also the Go button). I can also put a value into the apexir_SEARCH field of the IR with my javascript procedure.
              What I now need to proceed is to update the result and I thought I could do that easily with calling the gReport.search('SEARCH'); function. Like the Go button in the IR does it.

              What should come out is a rule which gets automatically created and the new result set of the IR.

              Only if I implement this gReport.search('SEARCH'); into my javascript the update process doesn't work anymore.

              Why I didn't want to use another item was to have the possibility to still changes the result set even if I put in a rule.

              Thanks for your support.

              Tobias
              • 4. Re: set Interactive Report in popup with start search value and submit
                Roel Hartman
                Maybe the page is not fully loaded yet when you fire your gReport.search? Try to call the JS function later, e.g. in the footer or in a region after your report region - or when you're sure the dom is completely loaded.
                Roel
                1 person found this helpful
                • 5. Re: set Interactive Report in popup with start search value and submit
                  Tobias Arnhold
                  I tried now to put this script:
                  &lt;script language="JavaScript" type="text/javascript">
                  set_ir_search_val();
                  &lt;/script>
                  under the Region Footer of the IR and page footer. Firebug still brings the same error:
                  gReport is undefined
                  set_ir_search_val()
                  (?)()
                  At least the Go button of the IR works again.

                  Any idea?

                  Tobias
                  • 6. Re: set Interactive Report in popup with start search value and submit
                    ATD
                    Hi,

                    If you do a View Source on your page, you should see:
                    &lt;script type="text/javascript"&gt;
                     addLoadEvent(init_gReport);
                     var gReport,gValid;
                     function init_gReport(){
                     
                    gReport = new apex.worksheet.ws('');
                     
                    gValid = new apex.validation.v();
                     }
                    &lt;/script&gt;
                    The addLoadEvent instructs the browser to add the init_gReport() function as a body.onload function, so will actually be the last thing the browser does. So, only once the browser has fully loaded the entire page, will gReport become available.

                    You can do one of two things - you'll have to experiment to see which works:

                    1 - Do the same sort of thing as the above to add your function using addLoadEvent(). This may overwrite the above, so
                    2 - Do the same sort of thing but include the init_g_report() at the top of your function to ensure that both functions run

                    Andy
                    1 person found this helpful
                    • 7. Re: set Interactive Report in popup with start search value and submit
                      Tobias Arnhold
                      Hi Andy,

                      I tried a bit more and found the script you mentioned. (In the created source code of my page.)
                      ...
                      &lt;/div>
                      &lt;script type="text/javascript">

                      addLoadEvent(init_gReport);
                      var gReport,gValid;
                      function init_gReport(){

                      gReport = new apex.worksheet.ws('');

                      gValid = new apex.validation.v();
                      }

                      &lt;/script>
                      &lt;div id="apexir_rollover" style="position: absolute; display: none;">
                      &lt;/div>
                      &lt;span id="apexir_LOADER" style="display: none;">
                      &lt;/span>
                      &lt;script type="text/javascript" language="JavaScript">

                      set_ir_search_val();

                      &lt;/script>
                      &lt;/td>
                      ...
                      It should get loaded before my js script starts. Anyway I put the script directly into my js:
                      function set_ir_search_val() {
                      addLoadEvent(init_gReport);
                      var gReport,gValid;
                      function init_gReport(){

                      gReport = new apex.worksheet.ws('');
                      gValid = new apex.validation.v();
                      }

                      var v_stop_js = document.getElementById('P105_STOP_JS');
                      if (v_stop_js.value != 1) {
                      var v_page = 'P' + '&P105_WHEREFROM.' + '_R_TIL_E_ID';
                      var v_from = opener.document.getElementById(v_page);
                      var v_to = document.getElementById('apexir_SEARCH');
                      v_to.value = v_from.value;
                      v_stop_js.value = 1;

                      gReport.search('SEARCH');
                      }
                      }
                      Still the same error occurs. Is there maybe another way to implement a dynamic rule into the IR when I open the page?

                      Regards,

                      Tobias
                      • 8. Re: set Interactive Report in popup with start search value and submit
                        ATD
                        Hi,

                        I think, to start with, it should be something like:
                        function set_ir_search_val() {
                        var v_stop_js = document.getElementById('P105_STOP_JS');
                        if (v_stop_js.value != 1) {
                        var v_page = 'P' + '&P105_WHEREFROM.' + '_R_TIL_E_ID';
                        var v_from = opener.document.getElementById(v_page);
                        var v_to = document.getElementById('apexir_SEARCH');
                        v_to.value = v_from.value;
                        v_stop_js.value = 1;
                        gReport.search('SEARCH');
                        }
                        }
                        addLoadEvent(set_ir_search_val);
                        Hopefully, this should load the function into the onload event after the init_gReport() function. If this doesn't do it, you could then try doing:
                        function set_ir_search_val() {
                        init_gReport();
                        var v_stop_js = document.getElementById('P105_STOP_JS');
                        if (v_stop_js.value != 1) {
                        var v_page = 'P' + '&P105_WHEREFROM.' + '_R_TIL_E_ID';
                        var v_from = opener.document.getElementById(v_page);
                        var v_to = document.getElementById('apexir_SEARCH');
                        v_to.value = v_from.value;
                        v_stop_js.value = 1;
                        gReport.search('SEARCH');
                        }
                        }
                        addLoadEvent(set_ir_search_val);
                        Andy
                        • 9. Re: set Interactive Report in popup with start search value and submit
                          Tobias Arnhold
                          Thanks Andy finally the second way you described worked for me.

                          It created automatically the new rule into my IR at the start up.

                          The JS function call I putted into my IR Region Footer.
                          Go Home>Application Builder>Application 301>Page 105>Edit Region> Region Footer
                          &lt;script language="JavaScript" type="text/javascript">
                          set_ir_search_val();
                          &lt;/script>
                          King Regards,


                          Tobias
                          • 10. Re: set Interactive Report in popup with start search value and submit
                            ATD
                            Glad to help Tobias!

                            Regards

                            Andy