PDA

View Full Version : how to display the portion of group on the report



Anonymous
09-11-2002, 11:14 AM
Hi,

Is there way to display only the group items which its group total meets some certain contitions? (e.g. group total on some column > 100). I know there is a item hide function but I don't want to see the blank space if the item is not visible.

Thanks.

Anonymous
09-11-2002, 03:44 PM
Hi,

difficult to impossible, I would say. Let me explain: The report is currently processed twice, the first run is the repaginate run, collecting the reportstates for the beginning of each page. The second run is the print run, this run can be started somewhere in the report by using the collected Reportstates of the prepare run.

So assume you sum the data in the prepare run. To collect the data, you have to wait until the group has ended, then you know the result and can decide whether to hide a band/element or not. The next chance where you an apply this is the print-run. But this run is not required to start from the beginning of the report, instead this run depends on the repaginating result of the prepare fun. So every page you look at, beginns where the report would start if all elements/bands were visible.

To solve the problem, you would have to know the result of the condition in the prepare run, so you will have to execute a run before the report is paginated, so you can use the result of this "sum"-run to hide the elements in the PrepareRun so that the ReportStates are valid durin the print-run.

So my solution to this problem would be: execute the Repaginate run once before you give the report to the reportpane (or before you print the report). For this "sum"-run set a property your function will recognize, make your calculations needed to resolve all depencies for the condition. After this run, alter the property so that your function knows that the "sum"-run is over. The ReportPane or the printing-method in the JFreeReportClass will now start a prepare run (and set the PrepareRun-Property). Now your function hides the bands and elements depending on the results calculated in the "sum"-run before. During the printing, your function has to repeat the hiding once more to create the same behaviour as on the prepare run (for the pageBreak-correctness).

For this solution many weird coning attacks are involved: Creating a reportState.Start() object clones the report. Functions are also cloned, so make sure you use the report from the Start-State instead of your original report after the "sum"-run is completed. When cloning the function make sure, that every function-instance has access to the results in an ordered way. Normaly JFreeReport takes care that every state uses the correct function-clone. A linear processing is simulated for every function by using the cloning and by storing the clone when proceeding to the next state.

But this implies that a stored (old) clone does not know the results a more advanced function will produce. Remember, you have to get the results of the last state (when the "sum"-run is finished) to feed that result in the real PrepareRun. So either add the results in a cloning-imune container (a list in the function for instance) or use the report properties as storage for your results. In both cases make sure, you can get the results of your calculations by accessing the Start-State (using getFunctions().get(name)... or State.getReportProperty()). These results have to be transfered to the report used in the Repaginate-Run. Then everything should run fine ...

Have more fun,
said Thomas

P.S.: Arrghh, You know that such ideas as yours cause the next version to grow :) A function depency will be added, so that you can define that the prepare run or anthoer function depends on the result of a previous run or function. Your question (and the depencies) also remove a problem with the layouting I currently have... thanks! Now I have to redesign everything, but the solution will be smarter :)