APEX Report with changing icons on row level

Von Tobias Arnhold 9.10.2008
If you want to show different icons based on a column value in your report.
Create a selection set for your report which works with the decode function (I used the example table emp):

Source code:

SELECT
e.empno,
e.ename,
decode
(e.job,
'PRESIDENT',
'<a title="President"><img src="#WORKSPACE_IMAGES#president.png" border="0" alt="president"></img></a>',
'MANAGER',
'<a title="Manager"><img src="#WORKSPACE_IMAGES#manager.png" border="0" alt="manager"></img></a>',
'ANALYST',
'<a title="Analyst"><img src="#WORKSPACE_IMAGES#analyst.png" border="0" alt="anaylst"></img></a>',
'<a title="Others"><img src="#WORKSPACE_IMAGES#other.png" border="0" alt="other"></img></a>')
AS only_with_job_icon,
decode(e.job,
'PRESIDENT',
'<a href="javascript:PopUpPage2_REPORT(''' || e.job ||
''');" title="President"><img src="#WORKSPACE_IMAGES#president.png" border="0" alt="president"></img></a>',
'MANAGER',
'<a href="javascript:PopUpPage2_REPORT(''' || e.job ||
''');" title="Manager"><img src="#WORKSPACE_IMAGES#manager.png" border="0" alt="manager"></img></a>',
'ANALYST',
'<a href="javascript:PopUpPage2_REPORT(''' || e.job ||
''');" title="Analyst"><img src="#WORKSPACE_IMAGES#analyst.png" border="0" alt="anaylst"></img></a>',
'<a href="javascript:PopUpPage2_REPORT(''' || e.job ||
''');" title="Others"><img src="#WORKSPACE_IMAGES#other.png" border="0" alt="other"></img></a>') AS link_via_js_and_job_icon
FROM emp e


Column description:
  • only_with_job_icon - Only show an icon without linking to any page
  • link_via_js_and_job_icon - Show an icon with linking to another page via javascript
Create the javascript for the link column: link_via_js_and_job_icon

Go into Page Attributes > HTML Header and add a javascript like:

Source code:

<script language="JavaScript" type="text/javascript">
function PopUpPage2(v_job){
url = "f?p=&APP_ID.:2:&SESSION.::::P2_JOB:" + v_job;

w = open(url,"winLov","resizable=yes,
scrollbars=yes,status=no,width=1152,height=768");

if (w.opener == null)
w.opener = self;
w.focus();
}
</script>

Post Tags: