Wednesday, 1 September 2010

Checking all Check boxes in a Manual Tabular Form

If you get into edit all page processes on one of your pages, you'll notice that the second tab accross is titled 'Delete multiple processes' (7400:745). This page also provides the same functionality, for checking all checkboxes in the column. You'll notice this elements onclick function is html_CheckAll($x_UpTill(this,'TABLE'),this.checked)

So, in your column header, using this will give you the same behaviour

<input type="checkbox" onclick="html_CheckAll($x_UpTill(this,'TABLE'),this.checked)" />

It is worth noting that html_CheckAll is not an apex documented function, so should be used with caution. In saying that, it is just  a wrapper for $f_CheckAll, which is documented - so it should be safe to use that function call instead of html_CheckAll. So the better input type would look like:

<input type="checkbox" onclick="$f_CheckAll($x_UpTill(this,'TABLE'),this.checked)" />

The function html_CheckAll is in the file apex_4_0_legacy.js. It calls a function $f_CheckAll, that is in apex_4_0.js. The function specification looks like this:

 function $f_CheckAll(f,e,c){
  var d;
  for(var b=0,a=d.length;b<a;b++){
   d[b].checked = e;