Author Topic: Display Elements belonging to Package as a Table  (Read 5058 times)

Screwtape

  • EA User
  • **
  • Posts: 93
  • Karma: +4/-0
    • View Profile
Display Elements belonging to Package as a Table
« on: February 03, 2016, 11:17:37 pm »
Hi! I've got a package which contains some requirements and I want to display them as a series of tables.

I've created a fragment which has a heading, and then a table in the element> section in the fragment. The fragment filters which requirement types I want, which is working.

The fragment is called by the main template, again in the element> section. I can's seem to call the fragment from any other section.

However, when I run the documentation, I get the whole fragment for each element - it puts the header in each time, and a complete table, rather than just the next row of the table.
When I create a number of fragments, each to show a table, then it becomes clear that each element is being processed by the main template in turn - the filtering in the fragment prevents the fragment occurring for the wrong element types, but what I want is each type to be grouped together under the package.

Any idea what I'm doing wrong? I really don't want to have to do this as a custom query, as the data I want is coming out fine.

Thanks!

Screwtape.
« Last Edit: February 03, 2016, 11:29:58 pm by Screwtape »
Screwtape

Uffe

  • EA Practitioner
  • ***
  • Posts: 1859
  • Karma: +133/-14
  • Flutes: 1; Clarinets: 1; Saxes: 5 and counting
    • View Profile
Re: Display Elements belonging to Package as a Table
« Reply #1 on: February 03, 2016, 11:44:14 pm »
Hello,


In passing, you can also place a fragment inside a package section; a fragment has both a #PACKAGEID# and an #OBJECTID# macro which you can use in queries.

If you've got the heading inside the fragment, it will be included every time -- it's not just what's inside the fragment's element section that gets output. Same thing if you place the heading inside the element section of the main template; everything inside the section gets repeated for each element.

The solution is to place the table heading in the main template, before the fragment call and outside the main template's element section.

So something like
Code: (Main template) [Select]
package>
| Name | Author | Description |
element>
{Template - Fragment template}
<element
<package

Code: (Fragment template) [Select]
package>
element>
| {Element.Name} | {Element.Author} | {Element.Notes} |
<element
<package

HTH,


/Uffe
My theories are always correct, just apply them to the right reality.

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13404
  • Karma: +567/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Display Elements belonging to Package as a Table
« Reply #2 on: February 04, 2016, 01:07:38 am »
Also make sure to mark the table as having a header row.
(somewhere in the right click options for the table)

Geert

Screwtape

  • EA User
  • **
  • Posts: 93
  • Karma: +4/-0
    • View Profile
Re: Display Elements belonging to Package as a Table
« Reply #3 on: February 04, 2016, 01:15:37 am »
Brilliant! Thanks!

What I've actually done is move the fragment to the package (I'd obviously been trying to add it to the packageElement rather than the package before), and put the heading in the package section of the fragment, and it works perfectly!

Code: [Select]
package>
| Name | Author | Description |
element>
| {Element.Name} | {Element.Author} | {Element.Notes} |
<element
<package
Screwtape