Question:
I have a field on a table with a hyperlinkReferenceExpression defined.
If this report is put on a dashboard or
is run in studio as an interactive report the hyperlinks work fine.
However, when hosted as a stand alone report in its
own web page (also in JSFiddle) the field looks like a hyperlink but behaves as a standard text field.
Please see the relevant part from visualize code below:
visualize({ auth: { name: "jasperadmin", password: "jasperadmin", organization: "organization_1" } }, function (v) { //render report from provided resource v("#container").report({ resource: "/reports/Production/Dashlet_Details/Oracle/Actions_Details", error: handleError }); //show error function handleError(err) { alert(err.message); } });
Answer:
In the visualize.js it is not enough to run the report to use hyperlink functionality.
You should define the behavior of hyperlinks via visualize code.
For more details please read
Visualize guide, CHAPTER 9 API USAGE - HYPERLINKS
https://docs.tibco.com/pub/js-jrs/6.2.1/doc/pdf/JasperReports-Server-Visualize.js-Guide.pdf
Below I quote a snippet of JavaScript Code that should enable
hyperlinks functionality in the test report (please find the report in the attachment to the article):
function (v) { v("#container").report({ resource: "/public/case_01459246/Actions_Details", linkOptions: { beforeRender: function (linkToElemPairs) { linkToElemPairs.forEach(showCursor); }, events: { "click": function(ev, link){ ev.stopPropagation(); if (link.type == "Reference"){ window.open(link.href); } console.log(link); } } }, error: function (err) { alert(err.message); } }); function showCursor(pair){ var el = pair.element; el.style.cursor = "pointer"; } });
Please pay your attention to the line:
ev.stopPropagation();
This line allows to disable Table Component's JIVE menu
that appears after the click on the hyperlink that is present
in table's data, please refer to the screenshot below:
Please find in the attachment to the article:
- a sample report that can be exported to your instance
of JasperReports Server. The sample is based on dummy sql
and JServerJNDIDataSource (the standard name of connection to
the Repository database). You can reconnect the report to any other
data source that is available in your environment
or update a name of the data source for your Repository
if it differs from the default one.
- visualize JS sample is represented by html page
that also contains JavaScript code. To use it you should update
all definitions of IP address of JasperReports Server that is available in your environment.
Recommended Comments
There are no comments to display.