Showing different memos on the databand depending on a field value?

edited 7:30PM in FastReport 4.0
Hello,

To simplify the description let's say I use the following data structure (I use a more complicated one, this is only to understand my problem):

The query describes the animals, but there are some specific fields only for certain animals.
For example the fields
- Name
- Kind (Birds or Mammals)
- Number of teeth (this applies only to mammals)
- Color (this applies to both)
- Wingspan (this applies only to birds)


Now I create Memos in Delphi on the fly as:

FrMemo := Frxd_CreateMemo(DataBandMaster); // this is my own function to create an FrMemo
With FrMemo Do
Begin
Text := 'Kind: [<frxDBDatasetAnimals."Kind">]';

TopText := TopText +5*fr01cm; //moving the cursor
Top := TopText ;
Left := MyLeftMargin*fr01cm ;
DataBandMaster.Height := DataBandMaster.Height+ (FrMemo as TfrxComponent).Height;
End;

If I use the method above, every field is visible, no matter if it is a bird or mammal, so the "Number of teeth" would be seen at Flamingo.

And I need the following:

Name: Flamingo
Color: Pink
Wingspan: 1.2

Name: Lion
Color: yellow
Number of teeth: 42

Name: Crow
Color: Black
Wingspan: 0.7

So depending on the value of Kind, Fr would show different memos.

My real data is much more complicated, I have about 20 common fields, 12 fields for one kind and 18 fields for the other kind, so If I would simply hide the memos which has fewer fields it would be a big gap vertically.

Can I do this somehow?



Comments

  • gpigpi
    edited 7:30PM
    Try to place each memo on separate child band and set child bands visiblity in script depend on the value of Kind
  • edited July 2011
    gpi wrote: »
    Try to place each memo on separate child band and set child bands visiblity in script depend on the value of Kind


    Hello,

    My problem is that there is a picture at left side, and the texts on the right (have a look at the picture attached)

    Fr_pict.jpg

    How can I add child bands vertically on the right, while the picture remains at the left? Should I use Vertical bands too?
  • edited 7:30PM
    Try to use side by side subreports. You can find an example in a standard compiled demo.
    Have a look at the picture below

  • Anu de DeusAnu de Deus Hampshire, UK
    edited 7:30PM
    Before I can present you with my solution can you tell me if Text1 to Text4 are the data values for different fields of the SAME record, i.e. the same animal, with same picture, and your picture and all MemoViews are in the same databand? And can you guarantee that if in every possible case there is enough room in the the band for all of the TextX?
    I mean, if an animal has all the fields populated, and considering the probable size of the contents of each memoview, will it always fit in that band?
  • edited 7:30PM
    Before I can present you with my solution can you tell me if Text1 to Text4 are the data values for different fields of the SAME record, i.e. the same animal, with same picture, and your picture and all MemoViews are in the same databand? And can you guarantee that if in every possible case there is enough room in the the band for all of the TextX?
    I mean, if an animal has all the fields populated, and considering the probable size of the contents of each memoview, will it always fit in that band?

    Yes, all fields are in the same dataset and all MemoViews are on the same databand. It will always fit in the band (I dynamically expand it).


  • edited 7:30PM
    Have a look at attached PDF file with the result of my tests.
    And if you find it interesting then source code (fr3) is attached as well.

  • edited 7:30PM
    Mick.pl wrote: »
    Have a look at attached PDF file with the result of my tests.
    And if you find it interesting then source code (fr3) is attached as well.


    Thank you.

    It is interesting, I can download the Fr, but if I want to download Pdf , I got the Error: Sorry, but you do not have permission to use this feature. If you are not logged in, you may do so using the form below if available.
  • edited 7:30PM
    When I log in I can open both files [img]style_emoticons/<#EMO_DIR#>/smile.gif" style="vertical-align:middle" emoid=":)" border="0" alt="smile.gif" /> I attach PDF file again and JPG of the part of first page. If you again meet problems with loading any of them then give me any suggestion for a way I can send those files to you. Mick[/img]
  • edited 7:30PM
    Mick.pl wrote: »
    When I log in I can open both files [img]style_emoticons/<#EMO_DIR#>/smile.gif" style="vertical-align:middle" emoid=":)" border="0" alt="smile.gif" /> I attach PDF file again and JPG of the part of first page. If you again meet problems with loading any of them then give me any suggestion for a way I can send those files to you. Mick[/img]

    Hello,

    I could download your last attachments, thank you (of course I logged in previously as well, otherwise I wouldn't have been able to download Fr).

    The output looks just as I wanted, I will check the Fr file.
  • edited 7:30PM
    You can easily run my example with FR compiled demo - it uses demo database and its pictures of fish.

    Mick

    PS.
    Sorry for misunderstanding your former post.
  • edited 7:30PM
    Mick.pl wrote: »
    You can easily run my example with FR compiled demo - it uses demo database and its pictures of fish.

    Mick

    PS.
    Sorry for misunderstanding your former post.

    Hello Mick

    Thank you very much for your example. Today I have had time to "transform" it into my environment and I can tell you that the solution is simple and yet amazing!

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.