Skip to main content



      Home
Home » Archived » BIRT » Drill Through - Passing List Box to Subreport fails
Drill Through - Passing List Box to Subreport fails [message #1021553] Wed, 20 March 2013 06:04 Go to next message
Eclipse UserFriend
Hi there,

I'm exploring the BIRT Report Designer and currently I'm trying to create a drill through from a chart.

Therefore I created two Reports:

- Master Report:
Displays Data Aggregated by Year

- Sub Report:
Displays Same Data as Master but aggregated by Month for one selected Year


The Master Report has several parameters. Some of them are list box parameters. Which means the user can choose multiple values.
The Sub Report has the same parameters. Additionally to that also a year parameter.


Now the problem:

In the Chart options of the Master Report I selected the Hyperlink Type "Drill Through" and chose the Sub Report.
I assigned the list box parameters from the master to the same list box parameter of the sub report.

This is not working. I think it is not possible to pass list box parameters to the sub report like that. Are there any other ways to achieve that?
Re: Drill Through - Passing List Box to Subreport fails [message #1021882 is a reply to message #1021553] Wed, 20 March 2013 17:20 Go to previous messageGo to next message
Eclipse UserFriend
I've attached an example that pulls customers from the classic models DB. It will allow multiple values in the parameter and pass them to the subreport. In the subreport it will change the query to match the parameters passed to it.

From the initialize() of the master report I had to separate each value by ~. I chose this because none of the customer names contain the character. Then I set the new separated string as a PGV.

importPackage(Packages.java.io);
importPackage(Packages.java.util);
importPackage(Packages.org.eclipse.birt.report.model.api);
importPackage(Packages.org.eclipse.birt.report.engine.api);
importPackage(Packages.org.eclipse.birt.report.engine.api.script.element);

myParam  = "NewParameter"; //report parameter
paramLen = reportContext.getParameterValue(myParam).length;
var thisParam = new String;

for (i = 0; i < paramLen; i++ ) {
  if(i > 0) {
    thisParam = thisParam + "~" + reportContext.getParameterValue (myParam)[i];
  }else{
    thisParam = reportContext.getParameterValue (myParam)[i];
  }
}

reportContext.setPersistentGlobalVariable("test", thisParam);

params["NewParameter"] = thisParam;


Now they are stored as a PGV I can call them in the expression builder of the drill-through link like this.

var values = reportContext.getPersistentGlobalVariable("test");
values;


In the beforeOpen() of the subreport I check to see if the parameter contains any value. If it does then I split the parameter into an array and modify the query.

if(BirtStr.charLength(params["NewParameter"].value) > 0) {
  var values = new String(params["NewParameter"].value);
  var temp = new Array();
  temp = values.split("~");
  var length = temp.length;

  this.queryText = "Select * from customers "
  this.queryText += " where  customername IN ("

  for(i=0; i<length; i++) {
    var thisCustomer = "'" + temp[i] + "'";
    this.queryText += thisCustomer;
    
    if(i != length-1 ) {
      this.queryText += ","
    }
  }

  this.queryText += " ) "
}


Take a look at the example and let me know if you have any questions. The example shows only one parameter but it should work with more than one with a few modifications.
Re: Drill Through - Passing List Box to Subreport fails [message #1022275 is a reply to message #1021882] Thu, 21 March 2013 11:39 Go to previous message
Eclipse UserFriend
Hi,

works like a charme. Thanks!
Previous Topic:PDF text wrapping issue in 3.7 version
Next Topic:Using system fonts on linux
Goto Forum:
  


Current Time: Sat Apr 26 21:03:08 EDT 2025

Powered by FUDForum. Page generated in 0.03759 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top