Skip to Main Content

Hacking APEX 3.2 $a_report function with jQuery

If you still running APEX 3, you can get APEX 4 dynamic action like feature to classic reports.

Load jQuery library on your page template header.
Create HTML region to page zero without template to position Before Footer. Place to region source

<script type="text/javascript">
$a_report=function (pId,pMin,pMax,pFetched,pSort){
 var url=$v("pFlowId")+":"+$v("pFlowStepId")+":"+$v("pInstance")+":FLOW_PPR_OUTPUT_R"+pId+"_";
 url+=pSort?pSort+"::RP":"pg_R_"+pId+":NO";
 $.ajax({
  url:"f",
  cache:false,
  type:"POST",
  dataType:"html",
  data:{
   p:url,
   fsp_region_id:pId,
   pg_max_rows:pMax,
   pg_min_row:pMin,
   pg_rows_fetched:pFetched
  },
  beforeSend:function(){
   $.event.trigger("htmldbReportAjaxStart",[pId]);
  },
  success:function(d){
   if($(d).attr("id")=="report_"+pId+"_catch"){
    $("#report_"+pId+"_catch").replaceWith(d);
    $.event.trigger("htmldbReportReady",[pId]);
   }
  },
  complete:function(){
   $.event.trigger("htmldbReportAjaxEnd",[pId]);
  }
 })
}
</script>

Now you can run own JavaScripts before and after report is partial refreshed (paginate or sort). Place to your classic report region footer

<script type="text/javascript">
$(function(){
 /* Before refresh */
 $("##REGION_ID#").bind("htmldbReportAjaxStar",function(e,p){
  if(p=="#REGION_ID#".substr(1)){
   alert("Before refresh");
  }
 });
 /* After refresh */
 $("##REGION_ID#").bind("htmldbReportReady",function(e,p){
  if(p=="#REGION_ID#".substr(1)){
   alert("After refresh");
  }
 });
});
</script>

Report cells are colored using JavaScript after you paginate or sort report.

Comments

No comments yet on this post