9 Replies Latest reply: May 23, 2013 3:04 AM by user237915 RSS

    APEX 4.0 Getting gReport is undefined when pulling IR report from Page2

    627092
      The below function used work perfectly in APEX 3.2 for
      Pulling Page2 IR Report into Page1 Region having <div id="XXHOLDER">
      <div>

      but in APEX 4.0, I am getting "gReport is undefined" when I click on IR Toolbar/Control panel like Action or Go

      function periodRep(){
      $.ajax({
      type: "POST",
      url: "wwv_flow.show",
      data: {
      p_flow_id : $v('pFlowId'),
      p_instance : $v('pInstance'),
      p_flow_step_id : "2",
      p_request : ""
      },
      dataType : "html",
      success : function(data){
      var startTag = '<apex2ajax>';
      var endTag = '</apex2ajax>';
      var start = data.indexOf(startTag);
      if (start > 0) {
      data = data.substring(start+startTag.length);
      var end = data.indexOf(endTag);
      data = data.substring(0,end);
      }
      $("div#XXHOLDER").html(data);
      $x_Value('pFlowStepId', "2");

      if($('#apexir_CONTROL_PANEL_COMPLETE').length > 0){
      if(!($('#apexir_CONTROL_PANEL_COMPLETE').css('display') == 'none')){
      gReport = new apex.worksheet.ws('');
      gReport.toggle_controls($x('apexir_CONTROL_PANEL_CONTROL'));
      }
      }
      }
      }); //ajax
      }//periodRep

      Please help
      Thanks
      -Senthil K
        • 2. Re: APEX 4.0 Getting gReport is undefined when pulling IR report from Page2
          627092
          Hello anybody there?,
          I created a test application. Try it and let me know.
          Your help in resolving this issue would be of great help to our project in upgrading from APEX 3.2 to 4.0

          http://apex.oracle.com/pls/apex/f?p=45684:1

          Click on "Customer Report" link on the side bar.
          It pulls the Customer Report from page2 to 1 using jquery ajax
          but none of the Action Tool Bar functions working...
          I tried using htmldb_get() function as well but still the same issue.

          -Senthil K
          • 3. Re: APEX 4.0 Getting gReport is undefined when pulling IR report from Page2
            Anthony Rayner
            Senthil K,

            This is great, thank you. Would you mind sending me workspace login credentials also to the email in my profile?

            Thanks,
            Anthony.
            • 4. Re: APEX 4.0 Getting gReport is undefined when pulling IR report from Page2
              Anthony Rayner
              Hi Senthil,

              I think that the reason this no longer works is due to internal changes we made to the Interactive Report JavaScript. These changes affected both how the IRR JS file was added to a page and also how the gReport variable is initialised.

              I would like to give you a few pointers as to what's changed and how you can get this working, but please bear in mind that doing these types of customisations is always going to be risky, due to the fact undocumented HTML that we output is always subject to change in future releases of APEX and cannot be relied upon as remaining the same.

              In 4.0, the IRR JS file is only included on a page where there is an IRR, so you're page 2. And unfortunately, due to the way you crop your response from page 2, this file is not being included in page 1 after the PPR. You therefore either need to change the way you crop the success data, or just include the apex_interactive_reports_4_0.js file on your page 1.

              Also in 4.0, we have also cleaned up a lot of initialisation JS code that we used to emit inline, that is now added at the end of the web document in a jQuery 'ready' handler. 1 such example of this code was the initialisation of the gReport variable in IRRs. This used to be emitted inline and was actually included inside of the snippet you crop within page 2 response. Which was all good. Now though, because this is done at the end of the response, which is outside of what you crop, this is no longer executed. Try adding the following initilialisation at the end of you 'success' callback:
              gReport = new apex.worksheet.ws('');
              gValid = new apex.validation.v();
              Again, to re-iterate!! Internal and undocumented code such as this is always subject to change and should not be relied upon as remaining the same in future releases of APEX. Only supported APIs and methods should be relied upon as being backwards compatible.

              Anthony.

              Edited by: Anthony Rayner on Jul 26, 2010 5:46 PM
              • 5. Re: APEX 4.0 Getting gReport is undefined when pulling IR report from Page2
                627092
                Anthony,
                You are the best. That was every helpful insight. I will give it a try.
                This would help slavage the PRODUCTION applications that were already built
                using this design (crop page by AJAX) when we upgrade to 4.0
                -Senthil K
                • 6. Re: APEX 4.0 Getting gReport is undefined when pulling IR report from Page2
                  627092
                  Anthony,
                  Using the above $.ajax code, how do I pull directly a "Saved Report" (say alias of the saved report 15488) instead of default "Primary Report"?
                  Thanks in advance
                  -Senthil K
                  • 7. Re: APEX 4.0 Getting gReport is undefined when pulling IR report from Page2
                    627092
                    Anthony,
                    I figured it out setting "Report ID Item" (Report Attributes > Advanced Attributes) passing the REPORT_ID value from table: Apex_Application_Page_Ir_Rpt
                    in the js function periodRep below.

                    The purpose is to create a "UL" (unOrdered List) tag listing "Saved Public Report" and user's "Saved Private Report"
                    in a Accordion-menu folder as Sidebar Region.


                    function periodRep(reportId){
                    $.ajax({
                    type: "POST",
                    url: "wwv_flow.show",
                    data: {
                    p_flow_id : $v('pFlowId'),
                    p_instance : $v('pInstance'),
                    p_flow_step_id : "2",
                    p_arg_name : 'P0_REP_ID',
                    p_arg_value : reportId,
                    p_request : ""
                    },
                    dataType : "html",
                    success : function(data){
                    var startTag = '<apex2ajax>';
                    var endTag = '</apex2ajax>';
                    var start = data.indexOf(startTag);
                    if (start > 0) {
                    data = data.substring(start+startTag.length);
                    var end = data.indexOf(endTag);
                    data = data.substring(0,end);
                    }
                    $("div#XXHOLDER").html(data);
                    $s('pFlowStepId', "2");
                    gReport = new apex.worksheet.ws('');
                    gValid = new apex.validation.v();
                    }
                    }); //ajax
                    }//periodRep

                    Edited by: Senthil_K on Aug 31, 2010 2:44 PM
                    • 8. Re: APEX 4.0 Getting gReport is undefined when pulling IR report from Page2
                      627092
                      Anthony,
                      I had the same issue of "gReport is undefined" with 4.2 when I upgrade from 4.0

                      This error went away when added this js script in page html header.
                      <script type="text/javascript" src="'+apex_img_dir+'libraries/apex/minified/widget.interactiveReport.min.js?v=4.2.0.00.27"></script>

                      or using the js code
                      $('<script type="text/javascript" src="'+apex_img_dir+'libraries/apex/minified/widget.interactiveReport.min.js?v=4.2.0.00.27"></script>').insertAfter('#apex-dev-toolbar');

                      Please let me know, whether this method is ok (I know even though this not documented and have risk during every upgrade) or
                      is there any other better way to do?

                      I value your opinion.
                      Thanks
                      • 9. Re: APEX 4.0 Getting gReport is undefined when pulling IR report from Page2
                        user237915
                        I had the same issue of "gReport is undefined" when I upgrade to 4.2.1.00.08.

                        I try to apply your solution but it doesn't succeed.
                        I put this code in "HTML header" of both pages: parent page and page wich is in the iframe:

                        <script type="text/javascript" src="'+apex_img_dir+'libraries/apex/minified/widget.interactiveReport.min.js?v=4.2.1.00.08"></script>

                        I try to apply the inicialization that Anthony indicates but it doesn't succeed too. I put this code in "Javascript" tab in the iframe page.

                        I try to add the js (apex_interactive_reports_4_0.js) that Anthony indicates but the script doesn't exists in my 4.2.1.00.08 installation.

                        What I could do?

                        Thanks,

                        Mark