Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2021-03

fpreport: can not use two ObjectLists as datasource in one report

14 messages · 3 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Andreas Frieß

I have a sample attached to show the problem.

I want in the report (created a runtime) to use more than one report datasource. I create a databand and connect this with a TFPReportObjectListData object. Each TFPReportObjectListData object works. But i want to have the data of the first, then the data of the other object. But i am not able to combine this two Data in one Report.

*--------------------*
   DataBand := TFPReportDataBand.Create(p);
   DataBand.Name:= 'DBBand01';
   DataBand.Layout.Height := 10;
   DataBand.Data:= lReportOLData1;   // First Data !!!!! This is shown
   Memo := TFPReportMemo.Create(DataBand);
   Memo.Layout.Left := 5;
   Memo.Layout.Top := 0;
   Memo.Layout.Width := 60;
   Memo.Layout.Height := 5;
   Memo.Font.Name := defaultFont;
   Memo.Text := '[InfoA] - [ValueA]';
   DataBand2 := TFPReportDataBand.Create(p);
   DataBand2.Name:= 'DBBand02';
   DataBand2.Layout.Height := 10;
   DataBand2.Data:= lReportOLData2;   // Second Data !!!!! This is not shown
   Memo2 := TFPReportMemo.Create(DataBand2);
   Memo2.Layout.Left := 5;
   Memo2.Layout.Top := 0;
   Memo2.Layout.Width := 60;
   Memo2.Layout.Height := 5;
   Memo2.Font.Name := defaultFont;
   Memo2.Text := '[InfoB] - [ValueB]';

*--------------------------*
Any Hint for this problem to solve ?

Reply by email

Michael Van Canneyt
to Andreas Frieß
Andreas Frieß wrote 38 lines
I have a sample attached to show the problem. I want in the report (created a runtime) to use more than one report datasource. I create a databand and connect this with a TFPReportObjectListData object. Each TFPReportObjectListData object works. But i want to have the data of the first, then the data of the other object. But i am not able to combine this two Data in one Report. *--------------------*   DataBand := TFPReportDataBand.Create(p);   DataBand.Name:= 'DBBand01';   DataBand.Layout.Height := 10;   DataBand.Data:= lReportOLData1;   // First Data !!!!! This is shown   Memo := TFPReportMemo.Create(DataBand);   Memo.Layout.Left := 5;   Memo.Layout.Top := 0;   Memo.Layout.Width := 60;   Memo.Layout.Height := 5;   Memo.Font.Name := defaultFont;   Memo.Text := '[InfoA] - [ValueA]';   DataBand2 := TFPReportDataBand.Create(p);   DataBand2.Name:= 'DBBand02';   DataBand2.Layout.Height := 10;   DataBand2.Data:= lReportOLData2;   // Second Data !!!!! This is not shown   Memo2 := TFPReportMemo.Create(DataBand2);   Memo2.Layout.Left := 5;   Memo2.Layout.Top := 0;   Memo2.Layout.Width := 60;   Memo2.Layout.Height := 5;   Memo2.Font.Name := defaultFont;   Memo2.Text := '[InfoB] - [ValueB]'; *--------------------------* Any Hint for this problem to solve ?

This is not supported as you write it.

You can have multiple datasources, but only 1 data band. If you need multiple data bands, you'll need to use master-detail.

If you want to use the second dataset in a memo expression, you must add it to the reportdatasets:

lReportOLData2.name:='Data2';
YourReport.ReportData.Add(lReportOLData2);

and in memo2 (which you must place somewhere else):

  Memo2.Text := '[Data2.InfoB] - [Data2.ValueB]';

I can't advise you on what bands you must place memo and how to advance the 2nd data list, because for that I would need to know the expected layout.

By the way, in

  if Assigned(rptExporter) then FreeAndNil(rptExporter);

etc.

The If Assigned() is not needed. FreeAndNil (or more accurately, Free) will already check this for you.

Michael.

Reply by email

Andreas Frieß
to Michael Van Canneyt

The expected layout is in the demo.

I have data inside of ObjectsList=OL (here in the demo two) and i want to report one OL by one. This should be done continuos and each OL have their own layout. There is no master-detail. After one OL is finished the next should be processed and appended, if the one page is finished, it should continued on the next page. This works for lReportOLData1 ok, but lReportOLData2 is never used/seen/reported.

Andreas

Michael Van Canneyt wrote 12 lines
..... I can't advise you on what bands you must place memo and how to advance the 2nd data list, because for that I would need to know the expected layout. .... Michael. _______________________________________________ fpc-pascal maillist - https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Reply by email

Michael Van Canneyt
to Andreas Frieß
Andreas Frieß wrote
The expected layout is in the demo.

'Expected layout' for me is a PDF, screenshot image of some finished document, showing what you want to see printed.

Show quoted text 7 lines
I have data inside of ObjectsList=OL (here in the demo two) and i want to report one OL by one. This should be done continuos and each OL have their own layout. There is no master-detail. After one OL is finished the next should be processed and appended, if the one page is finished, it should continued on the next page. This works for lReportOLData1 ok, but lReportOLData2 is never used/seen/reported.

In that case, you must put lReportOLData2 on a separate design page.

So:
* Add a design page (page 1) to the report.
* Do what you need with lReportOLData1 on this page.
* Add a second design page (page 2) to the report
* Do what you need with lReportOLData2 on this page.

That should be it.

Michael.

Reply by email

Andreas Frieß
to Michael Van Canneyt: 'Expected layout' for me is a PDF, screenshot image of some finished document, showing…
Michael Van Canneyt wrote 29 lines
On Thu, 18 Mar 2021, Andreas Frieß via fpc-pascal wrote: > The expected layout is in the demo. 'Expected layout' for me is a PDF, screenshot image of some finished document, showing what you want to see printed. > > I have data inside of ObjectsList=OL (here in the demo two) and i want > to report one OL by one. This should be done continuos and each OL have > their own layout. There is no master-detail. After one OL is finished > the next should be processed and appended, if the one page is finished, > it should continued on the next page. This works for lReportOLData1 ok, > but lReportOLData2 is never used/seen/reported. In that case, you must put lReportOLData2 on a separate design page. So: * Add a design page (page 1) to the report. * Do what you need with lReportOLData1 on this page. * Add a second design page (page 2) to the report * Do what you need with lReportOLData2 on this page. That should be it. Michael.

It is a joke, every ReportData need a new page.

I have tested it yet in the FPReportdesigner with a new project. I can add two ReportDatasources on a new report (eg. csv) and add to a report two Databands and connect every Databand with a datasource. If i press preview, i see the first data shown and the second is missing.

I thinks this is a issue in fpreport not to handle this correct. With LazReport i have done this without a problem.

Andreas

There

Reply by email

Andreas Frieß
to Andreas Frieß
Andreas Frieß wrote 18 lines
Am 18.03.2021 um 14:24 schrieb Michael Van Canneyt via fpc-pascal: > > In that case, you must put lReportOLData2 on a separate design page. > > So: > * Add a design page (page 1) to the report. > * Do what you need with lReportOLData1 on this page. > * Add a second design page (page 2) to the report > * Do what you need with lReportOLData2 on this page. > > > That should be it. > > Michael. It is a joke, every ReportData need a new page.

The issue is, fpreport handle the Databand not correct.

All have no Masterband set

A ) If i bound no Data to a Databand, automatic the dataset of the parent (Page) is used  -> Ok yet -> Dataloop of parent is used

B ) If i bound Data to a Databand and it is the same like the parent (page) -> Ok -> Dataloop of parent is used

C ) If i bound Data to a Databand and it is not the same like the parent -> Not Ok  -> the first it is handled like B  - it should use their own dataloop

You can make this with a fake working. Make a dummy Databand with a Dataset with ONE entry only. Then bound the datasets as childdatasets and it works.

You see the problem with the FPReport Designer too.

- Make a new report

- add two datasets (eg, csv with valid data)

- add PageheaderBand, TitleBand and PageFooterband

- add a Databand bound the Data1 to it

- add a Databand bound the Data2 to it

Make a Report Preview -> only the contend of the first dataset is shown.

I will file a bug

Andreas

Reply by email

Michael Van Canneyt
to Michael Van Canneyt
Michael Van Canneyt wrote 11 lines
On Fri, 19 Mar 2021, Andreas Frieß via fpc-pascal wrote: > Make a Report Preview -> only the contend of the first dataset is shown. > > > I will file a bug No need, because this is as designed.

For clarity: it's as designed, but that doesn't mean I won't consider changing the design. Just don't report it as a bug, because it is not.

Michael.

Reply by email

Andreas Frieß
to Michael Van Canneyt
Michael Van Canneyt wrote 22 lines
On Fri, 19 Mar 2021, Michael Van Canneyt via fpc-pascal wrote: > > > On Fri, 19 Mar 2021, Andreas Frieß via fpc-pascal wrote: > >> Make a Report Preview -> only the contend of the first dataset is >> shown. >> >> >> I will file a bug > > No need, because this is as designed. > For clarity: it's as designed, but that doesn't mean I won't consider changing the design. Just don't report it as a bug, because it is not. Michael.

For the record, is this written downwhat is 'by design' ?

For me it is a bug, because i can design a unuseable not working second Databand and i got no message. Nor Designtime, nor runtime. If it is not a bug, so a featurerequest must be possible, because other reports can handle this without a problem.

Andreas

Reply by email

Michael Van Canneyt
to Andreas Frieß
Andreas Frieß wrote 25 lines
Am 19.03.2021 um 11:07 schrieb Michael Van Canneyt via fpc-pascal: > > > On Fri, 19 Mar 2021, Michael Van Canneyt via fpc-pascal wrote: > >> >> >> On Fri, 19 Mar 2021, Andreas Frieß via fpc-pascal wrote: >> >>> Make a Report Preview -> only the contend of the first dataset is >>> shown. >>> >>> >>> I will file a bug >> >> No need, because this is as designed. >> > > For clarity: it's as designed, but that doesn't mean I won't consider > changing the design. Just don't report it as a bug, because it is not. > > Michael. > For the record, is this written downwhat is 'by design' ?

No. There are testsuites and some pages in the WIKI I obviously don't expect people to deduce the behaviour from those sources.

For me it is a bug, because i can design a unuseable not working second Databand and i got no message. Nor Designtime, nor runtime.

I expected this comment, and to a certain degree I can see your point.

But for me this is more akin to 'don't put your cat in the microwave to dry it' you can do it, but don't expect satisfactory results :-)

If it is not a bug, so a featurerequest must be possible, because other reports can handle this without a problem.

You can definitely submit a feature request. For severity, simply select 'feature'.

For completeness:
In general implementing it may be not so trivial as it seems:

First:
If there are 2 (or more) data bands, which one should I treat first ? The one that comes first in the internal list of bands, or the one that comes first when you visually design the report, or the dataset that comes first in the list of report data sets ? These orderings may not be identical....

Second:
For me it is also a question whether you should first loop the data of the first data band, and then loop the next. This is your case if I understood you correctly.

An equally valid approach would be to print one data band, then the other. Then advance both datasets. etc.

Which one to take depends on what output you need, obviously. (which is what I remarked on in my first reply)

Then the treatment groupings must be considered, page jumps etc.

Just to say it's far from trivial.

That is why I initially suggested making a second page in the report, because then this is all much less ambiguous.

But please submit a feature request, I will try to find a good solution.

For the time being, your approach with fake master detail will need to suffice...

Michael.

Reply by email

Andreas Frieß
to Michael Van Canneyt
Michael Van Canneyt wrote 10 lines
On Fri, 19 Mar 2021, Andreas Frieß via fpc-pascal wrote: > If it is not > a bug, so a featurerequest must be possible, because other reports can > handle this without a problem. You can definitely submit a feature request. For severity, simply select 'feature'.

Done: 0038639 , but i am not able to set the severity to 'feature'

Reply by email

Michael Van Canneyt
to Andreas Frieß
Andreas Frieß wrote 13 lines
Am 19.03.2021 um 13:34 schrieb Michael Van Canneyt via fpc-pascal: > > > On Fri, 19 Mar 2021, Andreas Frieß via fpc-pascal wrote: > >> If it is not >> a bug, so a featurerequest must be possible, because other reports can >> handle this without a problem. > > You can definitely submit a feature request. For severity, simply > select 'feature'. Done: 0038639 , but i am not able to set the severity to 'feature'

Hm. Strange. I did it for you.

Thanks for submitting the issue.

Michael.

Reply by email

Bart
to Michael Van Canneyt
PM Michael Van Canneyt wrote
> Done: 0038639 , but i am not able to set the severity to 'feature' Hm. Strange. I did it for you.

This has been disabled for "normal" reporters, since too many reporters marked their reports as major or even block.

Bart

Reply by email