Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.3k views
in Technique[技术] by (71.8m points)

delphi - How to show data at Fast Report in 3*3 grid format?

I want to display data from table (column :- ID) at FastReport in Grid format as shown below. Suppose there are 22 records in table then it would display same in 3 * 3 grid at FastReport in following manner.

enter image description here

I am using subreport at main page inside MasterData1 band. At subreport MasterData band is as follows

MasterData1 band

TfrxReportPage1 - Columns 2

enter image description here

Subreport - MasterData2 properties Columns 3 , RowCount 9

enter image description here

But when I previewed fast report it is just repeating same data in each grid on page as follows

enter image description here

I am using frxDBDataSet1 to display data (Number Of Records 9). There are in total 28 records so it is expected to show four 3*3 grids on page with 27 IDs. but rather it is repeating first 9 ID's in each 3*3 grid as shown above.

IF I set Number Of Records 0 at frxDBDataSet1 then it would show something like as below It is not forming 3 * 3 grid but shows data continuou enter image description here

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

EDIT since the previous* answer does not work with newer versions

Set rowcount to 9 for your masterdata band of the subreport.
In your mainreport, copy the masterdata band containing the subreport and insert it twice.
Put a headerband between the masterbands with property StartNewPage set to true.
Add OnBeforePrint events to the second and the third subreport to change the filter for the dataset.

procedure Subreport2OnBeforePrint(Sender: TfrxComponent);
begin
  TfrxDBDataSet(Report.GetDataset('frxDBDataset1')).Dataset.Filter := 'ID>9';  
  TfrxDBDataSet(Report.GetDataset('frxDBDataset1')).Dataset.Filtered := true;                                          
end;

procedure Subreport3OnBeforePrint(Sender: TfrxComponent);
begin
  TfrxDBDataSet(Report.GetDataset('frxDBDataset1')).Dataset.Filter := 'ID>18';  
  TfrxDBDataSet(Report.GetDataset('frxDBDataset1')).Dataset.Filtered := true;  
end;

enter image description here

(*) for older report versions, you can use an other approach, which stopped working between the versions 4.10.01 and 4.12.14.

Add an OnAfterPrint event to your memo on the subreport. Set the property StartNewPage to true after printing 9 "lines", Rowcount of the Masterband has to set to 1.

procedure YourMemoFromTheSubReportToRepeat9TimesPerPageOnAfterPrint(Sender: TfrxComponent);
begin
    MasterDataBandFromSubReport.StartNewPage := <Line#>  mod 9 = 0  
end;

enter image description here


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...