Event before "GetFieldValue"
i need to get an event exactly once just before the first
"GetFieldValue" (JITPipline) that starts a new DetailBand.
I tried "OnTraverseBy", "OnGetActive", "OnRecordPositionChange"
of the JITPipeline.
I also tried "BeforeGenerate" and "BeforePrint" of the
DetailBand.
All of the above fire either after GetFieldVale or fire more
than once before GetFieldValue.
Any suggestions?
Jens
"GetFieldValue" (JITPipline) that starts a new DetailBand.
I tried "OnTraverseBy", "OnGetActive", "OnRecordPositionChange"
of the JITPipeline.
I also tried "BeforeGenerate" and "BeforePrint" of the
DetailBand.
All of the above fire either after GetFieldVale or fire more
than once before GetFieldValue.
Any suggestions?
Jens
This discussion has been closed.
Comments
what do you want to achieve?
(ReportBuilder version?)
regards,
Chris Ueberall;
comes from is a TList with Items that should print and Items
that should be skipped.
Meanwhile i found out that skipping of data should be easier
by assigning all Items to the Job and then skip while printing.
I have Delphi 5 and RB 6.03. I tried this method now like this:
I start my print job in the unit that contains the TList:
PrintForm.ppJITPipeline.RecordCount := TourList.Items.Count;
PrintForm.ppReport.Print;
PrintForm.ppJITPipeline.Close;
The implementation code of my print form unit (conating the
report) is here:
const
clLightGray = $00F0F0F0;
function TPrintForm.ppJITPipelineGetFieldValue(aFieldName: string): Variant;
begin
if (aFieldName = 'Abfahrt') then Result :=
TourForm.TourList.Items[ppJITPipeline.RecordIndex].SubItems[1]
else if (aFieldName = 'Ankunft') then Result :=
TourForm.TourList.Items[ppJITPipeline.RecordIndex].SubItems[2]
else if (aFieldName = 'Fahrzeit') then Result :=
TourForm.TourList.Items[ppJITPipeline.RecordIndex].SubItems[3]
else if (aFieldName = 'KmStart') then Result :=
TourForm.TourList.Items[ppJITPipeline.RecordIndex].SubItems[4]
else if (aFieldName = 'KmEnde') then Result :=
TourForm.TourList.Items[ppJITPipeline.RecordIndex].SubItems[5]
else if (aFieldName = 'Kilometer') then Result :=
TourForm.TourList.Items[ppJITPipeline.RecordIndex].SubItems[6]
else if (aFieldName = 'Orte') then Result :=
TourForm.TourList.Items[ppJITPipeline.RecordIndex].SubItems[0]
else if (aFieldName = 'Zweck') then Result :=
TourForm.TourList.Items[ppJITPipeline.RecordIndex].Caption
else Result := 'xxx';
end;
procedure TPrintForm.ppHeaderBandBeforePrint(Sender: TObject);
begin
GrayBar := false;
end;
procedure TPrintForm.ppDetailBandBeforePrint(Sender: TObject);
begin
// Here i can determine if my TList.Item should print or not.
if TestBit(SetupForm.DriverMatrix,
TourForm.TourList.Items[ppJITPipeline.RecordIndex].ImageIndex) then
begin
// Item should print. I alternate the color of the DetailBand for better
readability.
if GrayBar
then ppGrayBar.Brush.Color := clLightGray
else ppGrayBar.Brush.Color := clWhite;
GrayBar := not GrayBar;
end
else begin
// Item should NOT print
ppJITPipeline.Skip;
end;
end;
This method however does not work. I get more records than i want. It looks
like the records i want to skip get printed sometimes. I still have to do
investigation about which record are not skipped correctly...
Maybe i should return to my inital idea that was:
- Counting how many TList items i want to print
- Assign that count to ppJITPipeline.RecordCount
- Retrieve the index of the next valid item while printing. This is,
where i need that event that fires once for every band before
calling "GetFieldValue".
Regards, Jens
I don't see from you code why you shouldn't be able to prepare the JITPipeline before printing - as you mentioned at end.
BTW, you could simplify the code in the 'GetFieldValue' event. I would use a stringlist to lookup the subitem's index.
You'd better compare (field)names in (ANSI)uppercase to avoid any notation issues.
regards,
Chris Ueberall;
Ok, according to my first idea i do the following:
- I traverse my TList and count all the Items i want to print
- I assign that count to 'ppJITPipeline.RecordCount' and
call 'ppReport.Print'
- I have a special function called 'NextValidItem' that
finds the next ItemIndex of my TList that i want for
printing.
- In 'ppJITPipelineGetFieldValue' i use a global integer
'CurrentIndex' to access my TList.Item
Question: Where do i call 'NextValidItem' to assign its result
to 'CurrentIndex'?
'BeforeGenerate' and 'BeforePrint' of the DetailBand get
called _after_ the corresponding calls to 'ppJITPipelineGetFieldValue'.
On the other hand, it looks much easier and straight forward
if i assign the total ItemCount to 'ppJITPipeline.RecordCount'
and could just skip whatever i want during printing...
So the real question is: How do i skip records with a
JITPipeline?
Regards, Jens
--
Dynamo Software | www.dynamo-software.de | Deutschland
Jens-Erich Lange | phone 04551-967755 | Germany
Kurhausstrasse 63 | fax 04551-967766 | Allemagne
23795 Bad Segeberg | mobile 0170-4072996 | Schleswig-Holstein
I would not only count the items, I would delete the unnecessary items!
If you can't delete them use another list and store the items of interest there.
regards,
Chris Ueberall;