Jump to content
JasperReports Library 7.0 is now available ×

Using same JRDataSource from master in sub


2005 IR Help

Recommended Posts

By: Steve Johnston - spjohnston

Using same JRDataSource from master in sub

2004-03-23 09:34

I am attempting to use the exact same data that is rendered in my Master report for my subreport. The data is just rendered differently. My subreport is to be rendered after all of the master's data (detail) has been rendered. So, in order to do this, currently, I'm putting the subreport in the master's footer. What I am finding is that the data source is already "spent" when it gets passed to the subreport. When using a debugger, I can manually "reset" the datasource just before the subreport is filled and it works beautifully. I see that some of the implemnetations of JRDataSource that is provided in the api also provide a moveFirst() method. However, how would that method get called? Is there a way that I can cause my datasource to be "reset" so that my subreport can iterate across the same data?

 

Thanks for any help that you can provide.

 

 

 

 

By: Chuck Deal - cdeal

RE: Using same JRDataSource from master in sub

2004-03-23 10:53

I believe there is a JRDataSource implementation called RewindableDataSource (or something close) that is either in the distribution or in the patches section.

 

As far as calling movefirst(), you may need a Scriptlet to trigger the call.

 

 

 

 

By: Steve Johnston - spjohnston

RE: Using same JRDataSource from master in sub

2004-03-23 11:45

Yes. Thank you for your reply. Shortly after my post, I found the RewindableDataSource. I changed my datasource to implment that interface and implemented the moveFirst() method. However, it appears that my need was not the intended use for this interface because the method does not get called automatically when passing the datasource to the subreport (not that I expected that it woud...it was just a shot in the dark).

 

That being said, would the best approach be to write a scriptlet to do this, or is there another "best" approach?

 

Any suggestions?

 

 

 

 

By: David Lim - aberrant80

RE: Using same JRDataSource from master in su

2004-03-23 19:49

Well, if you want to avoid a scriptlet, you could try placing the call to moveFirst in the printWhenExpression of the footer band or in the expression of a dummy text field. But then, because the method doesn't return anything, you might find it difficult to insert it as an expression.

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