Monthly Archives: June 2012

The function for APEX Interactive Reports

The gReport.searchfunction is used internally by Interactive Reports when a filter is applied on the report. Even if the function is not documented by Oracle, taking a look at the source code for the Interactive Report Search Field gives us a clue about how the function is used internally:

  <input title=”Search Report” type=”text” size=”30″ maxlength=”4000″ value=”” id=”apexir_SEARCH” onkeydown=”if($f_Enter(event))
            {‘SEARCH’); return false;}”/>
        onclick=”‘SEARCH’)” >

The code above defines the Search Field input item and adds the search action for when the Enter key is pressed:

onkeydown="if($f_Enter(event))          {'SEARCH'); return false;}

Similar code is used for the Go button:


The code snippets above reveals the fact that the‘SEARCH’) function is called to refresh and filter the Interactive Report on the fly, without refreshing the entire page.

Report filtering using gReport.Search

Using the function described above, you can create custom filter mechanisms on Interactive Reports. For example, you can create an Interactive Report dynamic filtering mechanism based on a simple select list.

  1.  Create a Select List item in the same region as the existing Interactive Report.
  2.  Fill in the Label field with the value P15_FILTER.
  3. For the List of Values Query, paste in the following query and create the item:select distinct JOB display_value, JOB return_valuefrom EMP
  4. Open the created select list and go to the Element Section. Set the HTML Form Element Attributes to: onchange=”filterReport()”
  5. This will trigger the filterReport() JavaScript function each time the select list value is changed.
  6. Edit the page when the Interactive Report and select list are created, go to the JavaScript tab and add the filterReport() function code in the Function and Global Variable Declaration:

function filterReport()
   var selList = document.getElementById(‘P15_FILTER’);
   var IR = document.getElementById(‘apexir_SEARCH’);
   IR.value  = selList.value;‘SEARCH’);

When selecting a value from the select list containing the job titles, the selected value will be assigned to the Interactive Report’s search field and the report will be filtered dynamically on this value.

The code above simply gets the select list value (document.getElementById(‘P15_FILTER’).value) and assigns it to the apexir_SEARCH item, which is actually the report’s search field. Then, the function is called to filter the Interactive Report.