APEX: Use CheckBoxes in APEX Report

Sometimes it is necessary to have a checkbox in the first row, in order to do something with the records (delete, update).

In this case we can use the following pieces of code in APEX in order to add some delete logic:

To show the checkbox in APEX report:

htmldb_item.checkbox(1, A.RECIPIENT_LIST_ID) " ",

which looks finally in html source like this:

...
<form action="wwv_flow.accept" method="post" name="wwv_flow" id="wwvFlowForm" >
...
<input type="checkbox" name="f01" value="59337"  />
...

to open (from button):

javascript:submitCheckBoxes();

and the javascript function required on the head of the page:

function submitCheckBoxes(){
    var theForm = document.wwv_flow;
    var theRecipientsList = "";
    for(i=0;i<theForm.f01.length;i++){
        if(theForm.f01[i].checked){
               theRecipientsList = theRecipientsList + theForm.f01[i].value + "|";
        }
    }
    if(theRecipientsList.length > 0){
        theRecipientsList=theRecipientsList.substr(0,theRecipientsList.length-1);
        GB_showCenter("Confirmation","http://myhost:8888/pls/apex/f?
        p=100:2:&APP_SESSION.::::P2_IDS_TO_BE_DELETED:"+theRecipientsList, 600, 500);
    }
}

to close (from child window):

javascript:parent.parent.GB_hide();

This example uses greybox, therefore the following are necessary in the head as well and the libraries to be uploaded:

<script type="text/javascript">
    var GB_ROOT_DIR = "/i/ont/greybox/";
</script>
<script type="text/javascript" src="/i/ont/greybox/AJS.js"></script>
<script type="text/javascript" src="/i/ont/greybox/AJS_fx.js"></script>
<script type="text/javascript" src="/i/ont/greybox/gb_scripts.js"></script>
<link href="/i/ont/greybox/gb_styles.css" rel="stylesheet" type="text/css" />

Leave a Reply