Use custom hyperlink handler with a Dashboard in JasperReports Server

Used jasper server version : 6.3.0

Problem Statement: Add hyperlink control for particular dashlet which will open drill-down in same dashboard page instead of opening drill-down report in new page.

Expected Output :

Expected output should be in one dashboard as shown below when we click on one dashlet hyperlink should open drill down report in same panel.

 

Step 1 : Click on any part of pie chart(HTML5) ie.department .
Lets assume if we click on department_id = 18 shown below :

 
Picture3

Step 2 : After click on department_id 18 we can see the difference it will reflect to drill down report which shows you the information related to department_id 18 and in input control automatically department_id as 18 will be selected shown below :

 
Picture4
 

If you select/click on another department_id should reflect in drill down report , you can try it.

 
Solution :

As mentioned above in expected output we created one dashboard having two dashlets.In it instead of passing hyperlink url we set constant value in hyperlink type as shown below :

 
Picture5
 

Or you can set it in source file(.jrxml) mentioned below :

 

  • Create a custom hyperlink type in your main report. Here’s an example for an HTML5 chart. In this case we named it “UpdateDashboardParams”(in source code):
  • Create a new Dashboard and put all your reports on canvas shown below:
  •  
    Picture6
     

  • Go to “Show Parameter Mapping dialog” in the Dashboard and manually create a filter (will create a section named “Manually Created Filters”) with the same name as it is produced by your custom hyperlink. In this example it is “Gender”. Then wire it to corresponding parameters in your “child” reports:
  •  
    Picture7
    *Property Name*
     
    Picture8
    *Show parameter mapping dialog*
     

  • Save the Dashboard.
  • Create a custom handler for your new hyperlink type, save it as dashboardHyperlinkHandler.js (in this case it is dashboardHyperlinkHandlerUpdateDashboardParams.js) should be same as constant value (Step 1) given for hyperlinkType otherwise it will not work.
  • Put dashboardHyperlinkHandlerUpdateDashboardParams.js to both /scripts and /optimized-scripts folders of your server deployment (.js file attached below):
  •  
    dashboardHyperlinkHandlerUpdateDashboardParams.js

  • Restart jasper server and see hyperlink in dashboard.
  • Open your dashboard in Dashboard Viewer and try hyperlinks.

 
Here I attached the same above mentioned example using HTML5 chart, you can refer :
 
Custom dashboard hyperlink using HTML5 chart Example
 
Custom_dashboard_hyperlink_HTML5_charts
 
Custom dashboard hyperlink using charts-pro Example
 

Here , we used charts-pro pie chart in dashboard for custom hyperlink , the functionality is same just little bit of chart data configuration is different in charts-pro.

 

Following are the steps to use custom hyperlink in charts-pro :

 

  • In jasper studio create new report.
  • From left side components-pro palette add charts-pro component and select pie chart.
  • Set series , categories and value expression according to you requirement under chart data.
  • Under Item Hyperlink set the constant value and its type which we previously used in HTML5 charts shown below :
  •  
    Picture9

  • Set hyperlink parameters under “Hyperlink Parameters” Section.
  • Now add your dashlets in dashboard :
  •  
    Picture10
     

  • Follow above Step 3 to set filters for drill down report shown below :
  •  

  • Save dashboard and follow above step 5 and step 6.
  • Restart jasper server and see hyperlink in dashboard.
  •  

    You can see the dashboard like this :

     
    Picture11
     

    Please find the attachment of above example(custom hyperlink dashboard using charts-pro)

     
    Custom_dashboard_hyperlink_charts_pro
     
    Reference:

    http://community.jaspersoft.com/wiki/how-use-custom-hyperlink-handler-dashboard-jasperreports-server
     

    Thanks,
    Sayali | Helical IT Solutions

    Leave a Reply