Newbie with many many questions

Hello!

I'm new with FastReports. Since I work with an object-oriented database
(FastObjects by POET), I don't use the BDE at all.
I have an internal data definition structure with Objects (corresponding to
BDE's TTables) and their fields.
Some of the fields are "normal-datatyped" fields (such as String, Number...),
other fields are pointers to one other object's dataset (1:1 relation),
and other fields are collections with pointers to other object's datasets (1:n).

Now I want to get this structure into the FastReport's Dictionary.

Putting them into the dictionary as variables doesn't work, because some
field names of one object (Table) also exist at another object, and the
Dictionary cannot handle multiple field names with the same name,
although divided by categories.

So, how can i put my objects and the three sort of fields into the Dictionary
of FastReport.
The example uses BDE to define the fields, so it doesn't help me much.

The algorithm should be:

For each object in the structure
{
Create a TTable-like object (???) and place it into FastReport (but where and how?)

For each field of the object
{
If it is a "normal" field
{
Add it to the TTable-like object (or where and how into FastReport?)
}
else if it's a 1:1 field {
// Field is a collection with pointers to other object-datasets
If it's "cascaded" (see below)
{
Treat it as "normal" field
}
else {
Create a Band-Datasource (where and how?)
}
}
else
{
// Field is a collection with pointers to other object-datasets
If it's "cascaded" (see below)
{
Treat it as "normal" field
}
else {
Create a Band-Datasource (where and how?)
}
}
}
}

Let's have an example:

CUSTOMER
.Name (String)
.Address (1:1-pointer to one ADDRESS-dataset)
.Orders (1:n-pointer-list to many ORDER-datasets)

ADDRESS
.Street (String)
.Town (String)
.Country (String)

ORDER
.No (Integer)
.Date (DateTime)
.Customer (1:1-pointer to the CUSTOMER-dataset)
.Invoices (1:n-pointer-list to many INVOICE-datasets)

INVOICE
.No (Integer)
.Date (DateTime)
.Order (1:1-pointer to the ORDER-dataset)


A CUSTOMER-report could look like:

1. The name of the customer (this is simple):
[.Name]

2. A band with the ADRESS data: In OnBeginBand-Event I would identify by
the band name ".Address":
[.Street] [.Town] [.Country]

3. For 1:1-relations it should also be possible to define a "cascaded" field:
[.Address.Street]


4. A detail-band with the ORDER data: In OnBeginBand-Event I would identify by
the band name ".Orders":
[.No] [.Date]

5. A detail-band with the INVOICE data: In OnBeginBand-Event I would identify by
the band name ".Invoices":
[.No] [.Date] [.Order.Customer.Address.Country]

I hope, the ".Orders" OnEndBand-Event did not yet fire
at this stage, so I would know, that ".Invoices" still belongs to the actual ORDER.
Or is my supposition wrong? If wrong, how could I know this?

The field [.Order.Customer.Address.Country] makes not much sense here,
but i shall show, what should be possible. I would scan this field name
in the OnGetValue-Event and return the appropriate value.

6. The first ORDER's number
[.Orders(0).No]

This also should not be FastReport's part to handle this, I would analyse
it in the OnGetValue-Event and return the appropriate value.


More questions / notes:

1. Can I globally change the field identification characters "[" and "]"
to - let's say - "{" and "}" ?

2. Bug? When the OnGetValue-event is used (coded), the OnUserFunction-event
is not more fired.

3. Bug? When the OnGetValue-event is used (coded), the field [PAGE#] must
also be handled by the OnGetValue-event. OnGetValue should have an
additionaly parameter: bool &Handled (in C++-syntax)
How can I get the value for [TotalPages]?

4. FastReport ignores manual settings of Dictionary.BandDataSources and
Dictionary.FieldAliases.

5. This is a real important question:
How can I hook into the Designer with an own MenuItem or ToolBar-Button.

I would like to add a new MenuItem or Button, that would open a window,
where I can select my fields and add a TFrMemo or TfrBandView into the report
at the current cursor position or line.

If this is not possible: how can I replace the Designer with my own ?
I tried to create a new TForm based on TfrDesignerForm, but showing this
form resulted in an access violation at runtime.

6. For every object in the report (mainly fields and bands) I should have the
possibility to give an "internal name". My objects and fields in my data
definition structure each have a unique ID. If I could give this ID to
the fields, bands, etc., I could make a report language-independent.
Let's say, that the fields has the name ".Country" and the internal
ID ".1234". FastReport would store both in the report file.
Now, when opening a report for designing, FastReport - for each field and
band in the opened report - would fire an event, where I could change the
field name and the band's name property, but not the ID.
So, I could translate ".Country" to (german) ".Land" , or the band
".Invoices" to ".Rechnungen".
I checked out some reporting tools and components, but none of all offered
me such a possibility. I wonder why...


Thank you in advance, and I hope, that I can all make with FastReports,
what I need. May be, some points are not yet possible, but would be new
features for your next version.

Best regards,
EKKR

Comments

  • gordkgordk St.Catherines On. Canada.
    edited 6:30AM
    Hi it is basically like getting values from an array. or string grid
    you will probably have to create variables with different names and use on get value events to retrive values for those variables.
    use fruserdatasets to control positioning in the rows, must write event handlers for on first, on next, on previous, on eof, events, and you may in some cases use virtual datasets of n records to control number of times a band repeats.
    and you will probably have to write onuserfunction events to pass values in and out of fr to external delphi code.
    onuserfunction is separate from ongetvalue.
    read up on where and when the bands print and the chapter on programming.
    regards ;)
  • edited 6:30AM
    Thanx, gordk, for your answer.

    Unfortunately, the main questions are left:
    Getting my data structure into the Dictionary - not as variables, but exactly like TTables (without having TTables). Perhaps I have to make my own DataSet, dereived from TDataSet, where i can specify my fields as FieldDefs... but this is not so easy. Did anyone yet do that? What of TDataSet's functionality would I have to implement, so that FastReports would accept it and show it in the Dictionary. Could I add this DataSet to the Dictionary dynamically, at runtime?
    If this all is not possible, could I "hook" into the designer with a new MenuItem. Then I could show my own Dictionary and insert my fields at the current cursor position, or bands at the current line.

    To the other points / bugs(?) - I checked it with a test program:

    1. When the OnGetValue-event is used (coded), the OnUserFunction-event
    is not more fired. Instead, my function is passed to the OnGetValue-event. This concerns a function, that I did not have registered. But FastReport should know, whether a symbol is a fields/variable or a function and pass it to the right event.

    2. When the OnGetValue-event is used (coded), the event also passes i.e. the field [PAGE#] to the event, and iI must handle this. But the documentation clearly says, that only unknown fields / variables are passed to the event.

    So, perhaps somebody of the FastReport team can answer all my questions, because I have to make the decision, whether we can use FastReport or not.

    Thanx again, gordk, for your efforts.

    EKKR

Leave a Comment

Rich Text Editor. To edit a paragraph's style, hit tab to get to the paragraph menu. From there you will be able to pick one style. Nothing defaults to paragraph. An inline formatting menu will show up when you select text. Hit tab to get into that menu. Some elements, such as rich link embeds, images, loading indicators, and error messages may get inserted into the editor. You may navigate to these using the arrow keys inside of the editor and delete them with the delete or backspace key.