How to run Javascript code for a PPR Report?

Maybe you have already used a PPR (Partial Page Rendering) report, by setting the “Report Template” property to “template: 7. Standard (PPR)”.

That’s quite a nice feature, because not the hole page is rendered when you are paginating through the report, just the report itself is refreshed with an AJAX call. But what happens if you want to run some Javascript code after the report content has been refreshed? For example to hide the “Select All” checkbox of the row selector.

If you put the code into the onload event or in the footer of the page, it will fire the first time when the page is rendered, but not when just the report content is refreshed with the AJAX call.

It also doesn’t help to put the code into the header or footer region of the report, because that part isn’t refreshed by the partial page rendering, just the content.

If you have read one of my previous posting about Auto Refresh Flash Charts, then you probably already know how it can work.

APEX has a Javascript function called init_htmlPPRReport which is called when the PPR report content is displayed and that gives us the opportunity to plug in our code into that function so that it is also executed.

Put the following example code into the “Region Header” of your report

<script type="text/javascript">
var vOriginal_init_htmlPPRReport = init_htmlPPRReport;

init_htmlPPRReport = function(pId)
  alert("init_htmlPPRReport called");

to be called each time the report content is displayed. I have also created a working example where you can try it out.

10 thoughts on “How to run Javascript code for a PPR Report?

  1. Nice example.
    There is a couple places in the Builder we have to do similar things.

    It will be a bit easier in 3.1 as the PPR reports and other Report AJAX/DHTML functionality will be encapsulated in a javascript object. Namespaced and everything 😉


  2. Hi Patrick,

    I am using ApEx 3.1, and want to do something similar to this, but using the $a_report function.

    Do you have any idea how this could be done as your example seems to only work for the “old” way of having PPR report templates, and not the “Enable Partial Page Refresh” option in the Report options.

    I look forward to hearing from you.

    Kind Regards,


  3. Hi Patrick,

    Thank you very much for getting back to me.

    I have tried to use your example in ApEx 3.1 with the “Enable Partial Page Refresh” set to “Yes”, and the modifications made to my Report region (added etc and the call to the init_htmlPPRReport function.

    The function is called, and an alert is shown when the page is first rendered, but when I click the pagination links (Using Scheme “Search Engine”) the report region is refreshed using PPR as expected, but the Javascript to generate the alert does not seem to be being fired.

    Is this due to the Pagination Scheme that I am using, or is there something else that I may have overlooked with regards to $a_report?

    I look forward to hearing from you regarding this.

    Kindest Regards,


  4. Hi again Patrick,

    I think I may have answered my own question there. The issue seems to be because I am using Pagination Type – “Search Engine” as opposed to “Rows X to Y”

    Please see an example on my ApEx page and the different way the 3 methods are being handled.

    The First uses PPR by setting the attribute in the Report Attributes section. This is the method I want to work with.

    The 2nd method uses the Search Engine, without the PPR attribute set in the Report attribute, this does not use Ajax calls and submits the page each time.

    The 3rd method uses the Rows X to Y pagination and performs as per your example.

    My quesstion then is how can I make additional javascript fire when using the “Search Engine” method and PPR?

    I look forward to hearing any suggestions from you.

    Kindest Regards,



  5. Hi Patrick.
    Can this be done in an interactive report?
    I’m having an issue with a jquery library where the library setting is missing when the report pagination is used.
    The best solution would be to set the library each time the report pagination is used. So I tried to use your solution (recommended by a colleague), but I can’t make it work.

    Best regards,

  6. I think using the methods above will execute before the ppr is rendered. Is there a way to execute after the ppr is rendered???


  7. Hi Sutherland,

    The only way I could get additional javascript to fire before/after the PPR is to overload the $a_report() function on each page that I want non-standard functionality.

    It is a litle clunky, but without modifying the seeded Apex JS there is very little else that can be done!


  8. Thanks Chris,

    I’m trying to implement row highlighting using jquery. It works fine when the report initially loads, but does not using ppr report navigation. I tried overloading the init_htmlPPRReport() function but it fires before the ppr is rendered, thus my js has no effect.

    I’ll try and overload the $a_report() built-in function and see what happens. I’m using apex 3.2.


Comments are closed.