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

Passing value from main report dataset to list dataset


lknueve

Recommended Posts

 Ok, so I'm assuming no one knows how to pass values from table/list dataset to main report....so my next question is does anyone know how to pass a parameter from main report dataset to sub-dataset for table/list? Since they're using the same query, I don't want the user to have to enter the same parameter 2 times.....

 

Thanks! 

Link to comment
Share on other sites

  • Replies 4
  • Created
  • Last Reply

Top Posters In This Topic

That I've done before.  I have a report called CardListing that takes as a parameter for the main report/dataset a parameter called CardTypeList that is of type java.util.List (it's a lot nicer on JasperReports Server, because I was able to create a multi-select input control based on a query of card types by description).  I use the parameter in my main data selection, but I also wanted to list what choices the user made in the summary.  I don't use tables yet, so I use a list, and I need to pass this parameter to the "DatasetCardTypeList" that I've associated with the List component that I dragged into my Summary band.

1. Create the parameter in your main dataset.

2. Drag the list into your band, and it automatically creates a subdataset for you.  I usually go and rename the subdataset to something meaningful.  I also specify the query for the subdataset at this point AND I create a parameter CardTypeList under the subdataset (in the Report Inspector tree, just expand the subdataset, and you'll see Parameters, Fields, Variables, and Groups...the Fields are populated from your query, but you create the parameters manually, just like in the main dataset).  In fact, I'm pretty sure you can right-click the CardTypeList parameter from your main dataset and choose Copy, then right click on the "Parameters" section of your subdataset and choose Paste to make sure the parameter has the exact same name and datatype (not necessary, but more intuitive, of course).  In fact, you might even want to create your parameter before your create your query, since your query probably includes your parameter in a WHERE clause.

3. Now for the glue that binds them together:  right click on the List (or Table, I presume) component in the Report Inspector Tree and choose "Edit List Datasource".  In addition to picking the correct sub dataset from the dropdown and probably setting the Connection/Datasource Expression to "Use connection expression" and keeping the default value of $P{REPORT_CONNECTION}, there is also a tab for Parameters.  Click on that tab and hit the "Add" button.  When you go to fill in the lefthand side "Parameter", it should show you a list of parameters that are defined in the subdataset (that's why it's better to do that ahead of time in step 2)  You won't see the $P{} syntax, because this side is assumed to be a parameter.  In this example, it's my CardTypeList parameter that I just created in step 2.  On the right side you fill in an expression...could be a field, variable, parameter, etc.  In this case, it's $P{CardTypeList} from the main report/dataset.

Hope that helps.  It looks harder than it is, just because I was trying to make the instructions fairly complete.  It doesn't take any time at all.

Carl

Link to comment
Share on other sites

  • 1 year later...

I know this thread is a bit old, but I'm facing the same issue here.  I'm new to Jasper Reports but I've noticed it's very similar to BIRT which is what we are migrating from.  In any case, I wanted to ask about your instructions to join a subquery parameter to the main report's parameter, particularly the instruction " right click on the List (or Table, I presume) component in the Report Inspector Tree and choose "Edit List Datasource".  I'm using iReport 4.7.0 and for the life of me I can't find a List item on the report tree.  Could this just be an issue with iReport versions? Again, I apologize for re-opening the thread but I can't seem any light on this subject.

Link to comment
Share on other sites

Its working in 4.7 . I just Passed value from main Report dataset to Table dataset.

 

YOU CAN DO THE FOLLOWIG

 

1) Create data set . Declare the required parameter in the subdataset

2) Drag drop table/chart

3) Right click on table/chart

4) Click on Parameter tab

5) click on add , now select the dataset parameter and set its value with corresponding main report parameter . Main Report parameter is getting value from prompt

6) Repeat step 5 for all other dataset parameter

Link to comment
Share on other sites

  • 2 years 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...