Expand my Community achievements bar.

July 31st AEM Gems Webinar: Elevate your AEM development to master the integration of private GitHub repositories within AEM Cloud Manager.

How to print a column in a second row


Level 1


I have been having this issue for a quite long time now, I want to print a nested table but I want to print it in a line below, like if the nested table were the last column but instead of being printed at right end of the table is printed in a row below.


The highlighted in purple is my nested table, is supposed that is info pertaining to the item 1. The line type is different so adding a row is not working for me so far.


9 Replies


Level 10

Sorry, but I don't get it. Can you please sketch how the table looks normally and how it should look when the form is printed?


Level 1


This is the Design View of the item table: as you know, all the orange section is the configuration of a single line:


As you can see, there are stacked subforms in the 4th column, they have flowed content that will not be displayed if their fields are empty and also they can increase their height depending on the content of its data. So the height of the row is variable depending on the available data.

Let’s say my item structure is currently like this:


The requirement is to add a details table if any of the components of the main product have a special tariff that affected the final price.

The item structure changed to be like:


Since there is no more space in the form, the request is to display the details below the actual data. I first added the nested table in a new subform in column 4th.

And I got this as result: the green part is the added table, which is the new field in the item structure.


Since still there isn’t enough space, the request is to move the data to the left, But I can’t do that because of the design:


If I try to add it, to any of the first 3 columns the table data is immediately printed in the row below and it will not respect the space taken by the subforms in the 4th column.

I tried to add a 2nd row and group them as a section, the second row containing the nested table.  I configured the section to repeat for each data item, and deleted this check box in both tables of the section, but the logic generated by the form is treating the 2nd table as an independent table, is not tied to the first one anymore, e.g if the second main item in my form doesn’t have details, is yet printing the next row in the tariff table, even though it pertains to a different item.

Hope I have explained myself a bit more clear this time.


Level 10

Can you please share the form. I don't see a way to help without knowing the actual structure of this form.


Level 1

Hi, thanks for your answer.

If you mean the xml file you can download from here:

SFPF_Z_FORM.XML - Google Drive

Or please let me know what exactly you would like to see.

Thank you.


Level 10

I was able to extract the nested XDP from you XML and load the form into my Designer. However, I cannot make it run at my end because of the missing data connections  and so.

Anyway, I think you'll only need a script to control the upper distance of you nested table in relation to the 4 stacked subforms in column 4.

Here's my suggestion:
Assuming you want to add a nested table in column 1: Wrap the POSEX field (orange) within a new flowed subform (black bordered) and add the new subform (blue) below. The vertical position of the nested subform (blue) depends on the height of the field (orange). You got that?


To control the fields height you need a FormCalc script in the layout ready event like this:

; Object references to subforms

var sf1 = Ref(SF_DESC.SF_IDNKD)

var sf2 = Ref(SF_DESC.SF_ARKTX)

var sf3 = Ref(SF_DESC.Cust_Ref)

var sf4 = Ref(SF_DESC.SF_ZZ_SERIAL)

; Calculate the overall height of all referenced subforms

var sfH = Concat(Sum($layout.h(sf1 , "mm"), $layout.h(sf2 , "mm"), $layout.h(sf3 , "mm"), $layout.h(sf4 , "mm") ), "mm")

; resize this field the the calculated height

$.h = sfH;


Level 1


Thank you so much for your help, I really appreciate that you take time to understand, I know is not easy nor my explanations are clear enough. I'll definitely try this approach since I have not tried this one before and is a very urgent topic now. My doubt is if I'm going to calculate the height of the fields, would the fields on column 4 have an already defined height? My thinking was that at execution time, the dynamic height of the "blue area" would be calculated before to know the final height of the fields on column 4 since the table would be in column 1. But will code this and update, thank you.


Level 1


I tried the suggested approach, this is what I have achieved so far:

1. Wrap posex field and add new subform: (checked)


2. Script:


I cannot make it work, not sure if the syntax is correct or where is the error, I have a couple of questions.

  • I wasn't sure about the level where should I place the code, If at the subform "SF_CUSTLI" level (Yellow area) or at the field "POSEX" level (Green area).
  • for the "Ref" function, I'm not sure if I'm addressing the objects correctly, I'm not sure if it should be like the squared in red option or like the squared in green.

This is the result I have so far:


The "Tariff Recovery" caption should have flowed till finish the S/N field. The above is an example of how the Serial Number section can grow without limit, all the rest rows inside the subform zz_desc remain the same height, only S/N can expand on demand.


Level 10

I think in that scenario you only have to reference to the the subform SF_DESC and take over its height for the POSEX field.

; Object references to subforms 

var sf1 = Ref(SF_DESC)

; resize this field the the calculated height 

$.h = Concat($layout.h(sf1 , "in"), "in")