Jump to content
JasperReports Library 7.0 is now available ×

passing data source


2005 IR Help

Recommended Posts

By: srini - kapsljava

passing data source

2004-03-16 22:56

hi all,

 

I want to generate the Master Report with sub report, I have set all the parameters and expressions in the main report for subreport.

 

code:

parameters.put("SubReport", subReport);

JasperFillManager.fillReport( mainReport, parameters, new JRTableModelDataSource(new CustomTableModel()));

 

Here in this code, Iam just passing the data source needed for main report, where i have to pass the data source needed for sub report.

 

Note: I got two Data sources for main report and sub report respectively..

 

Please Help Me!! Give some sample solutions..

 

Thanks in Advance

Srinivas

 

 

 

 

By: David Lim - aberrant80

RE: passing data source

2004-03-17 00:14

parameters.put("SubreportDS", subreportDS);

 

and inside subreport,

 

JRDesignParameter p = new JRDesignParameter();

p.setName("SubreportDS");

p.setValueClass(JRDataSource.class);

 

and make sure you pass the ds parameter from the main report to the subreport.

 

 

 

 

By: srini - kapsljava

RE: passing data source

2004-03-17 01:21

Thanks David,

 

How to pass the ds parameter from the main report to sub report?? please clarify iam not clear with that part...

 

Give me some samples

 

Thanks in advance

Srinivas

 

 

 

 

By: David Lim - aberrant80

RE: passing data source

2004-03-17 01:50

in your calling application

 

paramMap.put("SubreportDS", subreportDS);

 

in your main report

 

JRDesignExpression exp = new JRDesignExpression();

exp.setText("$P{SubreportDS}");

exp.setValueClass(JRDataSource.class);

subreport.setDataSourceExpression(exp);

 

you can actually learn this from looking at the API and the noxmldesign and doing some test runs you know.

 

 

 

 

By: srini - kapsljava

RE: passing data source

2004-03-17 02:11

Hi david,

 

Thanks

 

That thing i know and its working, but the report is not segregating the data according to the parameter i passed as city, It showing all the streets of subreport to the first city name which was passed..

 

For ur clarity: data matching both the data sources are city name.

 

main report data source contain only the name of the city

 

subreport data source contains the id,name,street,city

 

my question is that anything i have to match with the city in the sub report??

I have an sample subreport example in that they r using database connection, and they also matched the parameter.

xml:

<queryString><![CDATA[

SELECT Product.ID AS ID, Product.Name AS Name, Position.Quantity AS QUantity, Position.Price AS Price FROM Position, Product, Document, Address WHERE Position.DocumentID = Document.ID AND Document.AddressID = Address.ID AND Position.ProductID = Product.ID AND Address.City = $P{City} ORDER BY Product.ID

]]></queryString>

 

in the above code they r matching the parameter $P{City}

 

Thanks in advance

srinivas

Link to comment
Share on other sites

  • Replies 0
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

Top Posters In This Topic

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...