Tuesday 25 September 2012

Check All check boxes in oracle apex report

If you have a report that contains check boxes (to do this see the APEX_ITEM API) you may want add a function to check or uncheck all of the boxes at once.

To do this in a standard report change the name of the column in the report attributes to

"<input type="Checkbox" onclick="$f_CheckFirstColumn(this)"><span>Column name here</span>"

This creates a check box in the title that when checked will check all of the boxes. However if you have an interactive report this solution is not suitable as clicking on this top check box will bring up the column sorting and filtering options.

In this case the solution can be found in an Apex Njnja's white paper on page 17

The solution from this paper is quoted here


Select/unselect all

Another functionality that is a must, especially when working with many rows, is a select/unselect all.
This can be done by creating an item situated in the IR region, located above the region. Create the item
as display as text,without any label. Then, in the Pre Element Text region, paste this code:

"<input type="button" name="CheckAll" value="[+]"
onClick="checkAll(f01)">
<input type="button" name="CheckAll" value="[-]"
onClick="uncheckAll(f01)">"

This will add the two buttons on your screen:

Now, add the two javascript functions inside you page HTML  Header :

"<SCRIPT LANGUAGE="JavaScript">
<!-- Begin
function checkAll(field)
{
for (i = 0; i < field.length; i++)
{field[i].checked = true;}
}
function uncheckAll(field)
{
for (i = 0; i < field.length; i++)
{field[i].checked = false ;}
}
</script>"

These functions will be called when clicking the two buttons created before and will check/uncheck all
of the checkboxes from the IR.



No comments:

Post a Comment