Mostly ORACLE APEX and Windsurfing stuff

Saturday, 12 November 2011

Read all IDs from an Interactive Report

So you like the functionality that interactive reports give you and would like to integrate it with a third party application such as Google Maps or an embedded java applet. The challenge is to read the currently filtered and sorted report rows and pass them into the third party application; a pretty straight forward task with JQuery, but how do you cope with the pagination?

This is a nice trick; hide the report, display all the rows, read them and return the report to the original state. Like this:

Demo

Here's how I did it.

Add a hidden item to a column in the report and uncheck the hide option in the iR settings so that it cannot be removed from the report. e.g.

apex_item.hidden(1,empno)||empno empno

Set Function and Global Variable Declaration:

function f_get_ids() {
// read the start pagination
var l_start_pag = $('#apexir_ROWS_PER_PAGE_MENU .dhtmlSubMenuSelected').children().attr('href');
// after refresh function
$('#report').one('apexafterrefresh', function () {
$s('P47_IDS', f_conc_ids());
$('#form_LOADER').hide();
window.location = l_start_pag;
});
// reset the text item
$s('P47_IDS', '');
f_show_form();
// show all rows in report
javascript: gReport.search('SEARCH', 100000);
}

// Function to read all ids on report
function f_conc_ids() {
var lv_ids;
$('[name="f01"]').each(function () {
if (lv_ids) {
lv_ids = lv_ids + $(this).val() + ':';
} else {
lv_ids = $(this).val() + ':';
}
});
return lv_ids.substring(0, lv_ids.length - 1);
}

function f_show_form() {
$("#report").hide();
$("#form").show();
$('#form_LOADER').show();
}

function f_hide_form() {
$("#form").hide();
$("#report").show();
}


Set HTML Header:

<span style="position:absolute;top:4px;left:48%;display:none;" id="form_LOADER">
<img src="/i/ws/ajax-loader.gif">
</span>

1 comment:

Andy said...

Very nice!

As it so happens, exactly what I was looking to do in an app at the minute :)