Jump to content
We've recently updated our Privacy Statement, available here ×
  • Visualize.js: a hyperlink in report works in JasperReports Server but not in Visualize, how to fix this?


    akonkin
    • Features: Reports Version: v6.3 Product: Visualize.js

    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:

    jive_menu(2).png.c36381fb0ec81ac2f54270b6c7a54e2d.png

    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.

     

     

     

     

     

     

    case_01459246_1.html

    case_01459246.zip


    User Feedback

    Recommended Comments

    There are no comments to display.



    Guest
    This is now closed for further comments

×
×
  • Create New...