Jump to content
We've recently updated our Privacy Statement, available here ×

Passing Parameter to a Subdataset?


gconsultant

Recommended Posts

For roughly the past week, I have been trying to pass a parameter from my main report to a subdataset for use in a bar chart via a dataset run.  The examples provided in "The Definitive Guide to iReport" are extremely basic and provide little in the way of specific configurations of a dataset run.

I was wondering if anyone here could provide a quick step-by-step explanation of how to pass a parameter to a chart/subdataset via a data set run?

I am using iReport 3.1.2.  I can provide my XML code and any additional details if they would be of any help.

 

Thank you very much in advance.  This problem has been a real nightmare.

Link to comment
Share on other sites

  • Replies 8
  • Created
  • Last Reply

Top Posters In This Topic

Thank you for the response - I actually just solved my issue also.

There appears to be a bug in iReport when adding a chart subdataset run parameter with the GUI. When the parameter is added (and the corresponding dataset parameters have been established), the following error is reported:

 

"Class not set for dataset [dataset name] parameter expression: [parameter name]."

This error occurs regardless of parameter map settings or connection/datasource settings. I was able to circumvent the error by adding the parameter in the XML view. Is there a way to forward this error to the developers for correction in a future update?  Thanks!



Post Edited by Grant Dole at 01/27/09 21:16
Link to comment
Share on other sites

  • 1 month later...

I was able to make the change by adding the dataset run via the xml view.  Trying to make any changes to the chart's dataset run via the GUI caused it to break again.  It will probably work if you do it with the GUI, then go into the xml, change something, change it back, and save it.  Just don't try doing any other edits to the chart dataset selection with the iReport GUI interface.

Here is an xml snippet (which was generated originally by the GUI):

 

Code:
<dataset>	<datasetRun subDataset="Subset - Revenue">		<parametersMapExpression>			<![CDATA[$P{REPORT_PARAMETERS_MAP}]]>		</parametersMapExpression>		<datasetParameter name="ChartID"><datasetParameterExpression>![CDATA[$F{IDDefinition_IDNumber}]]></datasetParameterExpression></datasetParameter><connectionExpression><![CDATA[$P{REPORT_CONNECTION}]]></connectionExpression></datasetRun></dataset>
Link to comment
Share on other sites

  • 2 years later...

I ran into that problem too ( 2 years after gconsultant had the problem)

with a <jr:table> which is bound to a subDataset.

Look at the bugtracker id 1227, it is a well known issue:

My Solution that works in iReport:

To <connectionExpression> in the <datasetRun> I added the report parameter map

in the XML-View by hand and that solved my problem

Code:



Post Edited by photonflux at 08/03/2011 10:13



Post Edited by photonflux at 08/03/2011 13:03
Link to comment
Share on other sites

For the subdataset that you use in the chart you have to "duplicate" the variables from the main report.

In the report designer choose the subdataset and add variable

with the same name as in the main report if you like.

But the DefaultValueExpression of the subdataset variable must point to the value of the "main variable":

$P{main_variable}

 

It is possible that a chart will work with no further manual manipulations at the xml.

If not

repeat the parametersMapExpression in the subdataSet

in the xml View  as described above.

Link to comment
Share on other sites

  • 1 year later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...