Hi all!
I need to put hyperlinks in my APEX (4.0) Report and I read there is no direct option for it... this is how I thought to do, then...
My reports contains two columns:
DEVICE and HEALTH.
The first contains a String with Devices' name, and the second a Number to be intended as percentual.
I need Strings in DEVICE columns are also links to another APEX page where I have to generate a "dynamical" chart.
I.E.: we can intend a Report Row where DEVICE is "000x0" and HEALTH "30".
APEX generate HTML like this:
<td headers="DEVICE" class="data">000x0</td><td headers="HEALTH" class="data">30</td>
But I also need "000x0" to be a link to: "f?p=104:4:2205607043123699::::THE_DEVICE:000x0".
As to say: the fourth page of my APEX site, where "THE_DEVICE" is an APPLICATION_ITEM and it have to contains the name of clicked Device.
First thing I tried is to re-write pl/sql query to automatically returns html code for the link, like:
select
'
'||DEVICE||'' as DEVICE,
trunc(HEALTH, 2) as HEALTH
from [...]
But APEX convert special characters to &x; values:
&lt;a href=&quot;f?p=104:4:2205607043123699::::THE_DEVICE:000&quot; target=&quot;_self&quot;&quot;&gt;000&lt;/a&gt;
Second thing I thought is to give an Unique ID to Report's Region ("ALARM_DEVICES_REG") and try to modify that text dynamically by adding JavaScript to Footer Region.
I checked and found in this forum a JavaScript suggested to somebody which had similar problem to mine, then I tried to adapt to my situation.
The fact is that my JavaScript in Footer Region doesn't seems to work at all! Neither a simple document.write("bye!"); comand!
How possible?
The JavaScript I tried to create could also contains errors, and it's the following:
<script type="text/javascript">
var y = document.getElementById('report_ALARM_DEVICES_REG')
var x = y.getElementsByTagName('TD');
var s;
if (x)
{
for (var i = 0; i < x.length; i++)
{
s = x.item(i);
if(s.getAttribute('headers') == 'DEVICE')
{
s.data = replaceHtmlEntites(s.data);
}
}
}
</script>
I noticed the innerTable for Reports area has "report_ALARM_DEVICES_REG" id (while the outer has "ALARM_DEVICES_REG") so I used it to be more selective.
replaceHtmlEntites is a function which should bring back special character from "&x;" values, and it's the following (I put it in "Function and Global Variable Declaration" area of Report's APEX page):
var replaceHtmlEntites = (
function() {
var translate_re = "/&(nbsp|amp|quot|lt|gt);/g";
var translate = {
"nbsp": " ",
"amp" : "&",
"quot": "\"",
"lt" : "<",
"gt" : ">"
};
return function(s) {
return ( s.replace(translate_re, function(match, entity) {
return translate[entity];
}) );
}
})();
Shouldn't this work? And if not, why?
Thank you all!