Book a Demo

Author Topic: RTF Eport How to hide empty elements inside Table or other ideas  (Read 3940 times)

xabi

  • EA User
  • **
  • Posts: 21
  • Karma: +0/-0
    • View Profile
RTF Eport How to hide empty elements inside Table or other ideas
« on: December 04, 2023, 02:29:30 am »
Perhaps you can help me with the following challenge.

I created a Fragement Template which execute an custom SQL the Result should display a table. This works great but Im not happy with the printed file.

Example Template:

FieldName       Behaviour
{Name}          {CopyField}
                      {SignificantEdit}
                      {HiddenField}

Some Fields have for example only the Behaviour HiddenField. But unfortunately the created document contains empty spaces for the CopyField and SignificantEdit.

Is there any possibility to remove this empty spaces?

I already tried the following but the result was also not the best approach :(
FieldName       Behaviour
{Name}          {CopyField}{SignificantEdit}{HiddenField}

Thanks in advanced


« Last Edit: December 04, 2023, 02:51:47 am by xabi »

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: RTF Eport How to hide empty elements inside Table or other ideas
« Reply #1 on: December 04, 2023, 06:50:08 pm »
You can use bookmarks to with <tagName>.Start and <tagName>.End to indicate that the document generator can skip that part of the tag is empty.

That works to eliminate extra newlines.
Only limitation is that you can't place twoo bookmarks at the same location. That is annoying when you have multiple tags separated by newlines.

Geert

xabi

  • EA User
  • **
  • Posts: 21
  • Karma: +0/-0
    • View Profile
Re: RTF Eport How to hide empty elements inside Table or other ideas
« Reply #2 on: December 04, 2023, 11:37:08 pm »
Hi Geert,

thanks for your reply and help. Unfortunately it is still not working. Im sure Im doing something wrong.

Do you mean like the following:

FieldName       Behaviour
{Name}           <SignificantEdit>.Start{CopyField}{SignificantEdit}{HiddenField}<SignificantEdit>.End

Does it mean that it will not be dipslayed if the fieldName does not have the SignifcantEdit

Thanks in advanced


Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: RTF Eport How to hide empty elements inside Table or other ideas
« Reply #3 on: December 05, 2023, 03:09:04 am »
See https://sparxsystems.com/enterprise_architect_user_guide/16.1/model_publishing/using_bookmarks.html

Especially the part:

Quote
All .Start and .End bookmarks that enclose a labeled field will hide the label in the report if the field has no content; for example:

The bookmarks Element.Keywords.Start and Element.Keywords.End enclose the Keywords {Element.Keywords} report field, but if an element has no keywords, the Keywords label in the generated report is hidden and the space closed up

Geert

xabi

  • EA User
  • **
  • Posts: 21
  • Karma: +0/-0
    • View Profile
Re: RTF Eport How to hide empty elements inside Table or other ideas
« Reply #4 on: December 05, 2023, 04:50:09 am »
Thanks Geert for your support I think I understand it now better.

I think Im also now understanding your comment regarding the restriction. If I write everything in one line the complete line disappear.
Bookmarks for tags separated by newlines are not working. Is that correct?

Do you have any idea how I can display it in a nice format?

Thanks in advanced

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: RTF Eport How to hide empty elements inside Table or other ideas
« Reply #5 on: December 05, 2023, 05:29:11 am »
No, what I'm saying is that you can do


Code: [Select]
otherInfo <field.Start>
{field}<Field.End>

This will only add a newLine when {field} has contents.

What you can't do is

Code: [Select]
otherInfo <field.Start>
{field}<Field.End><otherField.Start>
{otherField}<otherField.End>

Because you then have two bookmarks at the same location, and that is not supported.

But since you are using an SQL Fragment, it might be easier to include the (optional) newlines in a single field in your SQL.

Geert



xabi

  • EA User
  • **
  • Posts: 21
  • Karma: +0/-0
    • View Profile
Re: RTF Eport How to hide empty elements inside Table or other ideas
« Reply #6 on: December 06, 2023, 01:37:17 am »
Hi Geert thanks again for your help. I tested it and the approach does not work for me. Thanks for your hint regarding the SQL I think with concat I can solve my problem :)

Do you have a hint for me how I can add CHAR(13) CHAR(10) or a empty space between the Strings.

Here my snippet:

Select a.Name, a.Notes, #Concat tvc.Property, '; ' # as 'CopyField', #Concat tvs.Property, '; '# as 'Significant', #Concat tvh.Property, ';' # as 'HiddenField'

The spaces are removed :(

Thanks in advanced

xabi

  • EA User
  • **
  • Posts: 21
  • Karma: +0/-0
    • View Profile
Re: RTF Eport How to hide empty elements inside Table or other ideas
« Reply #7 on: December 07, 2023, 05:23:52 am »
Short Update:

I tried the following and it works if all properties are found. If one is property is missing the hole line is not displayed.

Code: [Select]
select a.Name, a.Notes,' ' + CHAR(10) + tvc.Property + CHAR(10) + '' + tvh.Property + CHAR(10) + ' '+ tvs.Property + CHAR(10) + ' '+ CHAR(10) +' ' as test
Then I tried the following approach. All elements are displayed also if one is missing but the line breaks are ignored.

Code: [Select]
select a.Name, a.Notes,' ' + CHAR(10) + tvc.Property + CHAR(10) + '' as test, '' + CHAR(10) + tvh.Property + CHAR(10) + '' as test2
Any hint is welcome

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: RTF Eport How to hide empty elements inside Table or other ideas
« Reply #8 on: December 07, 2023, 03:45:20 pm »
use coalesce(tvc.Property, '')

Geert

xabi

  • EA User
  • **
  • Posts: 21
  • Karma: +0/-0
    • View Profile
Re: RTF Eport How to hide empty elements inside Table or other ideas
« Reply #9 on: December 07, 2023, 07:33:46 pm »
Hi Geert, you are as always amaizing ;) thanks for your support and ideas. Im getting closer

But still the spaces after ; are removed. Is there any escape character or something like that.

Code: [Select]
select a.Name, a.Notes, COALESCE(tvc.Property+"; ",'') as test, COALESCE(tvh.Property+"; ",'') as test2, COALESCE(tvs.Property,'') as test3
The output looks now like that:

tvc.Property;tvh.Property;tvs.Property

Want I want is:


tvc.Property; tvh.Property; tvs.Property

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: RTF Eport How to hide empty elements inside Table or other ideas
« Reply #10 on: December 08, 2023, 06:09:06 am »
Then add the spaces and newlines like you did before.

The reason they it showed nothing is because null + "some string" = null, but "" + "somestring" = "somestring"

Geert

xabi

  • EA User
  • **
  • Posts: 21
  • Karma: +0/-0
    • View Profile
Re: RTF Eport How to hide empty elements inside Table or other ideas
« Reply #11 on: December 15, 2023, 08:20:36 pm »
Hi Geert, sorry for the late answer. I was able to fix my problem with your help. Thanks again and have a nice day