How to modify height of textfield of repeating table using Javascript | Adobe Higher Education
Skip to main content
Level 2
October 31, 2019
解決済み

How to modify height of textfield of repeating table using Javascript

  • October 31, 2019
  • 19 の返信
  • 21790 ビュー

Hello guys,
I need to change, by javascript code, the height of a textfield of a table repeatable n times and connected to a data connection, in order to have the same height for each textfield of each repeatable table.

Below is a screenshot of the structure of my form:

This is my Javascript code written in event layout:ready of subform "subTab":

var numTab = xfa.resolveNodes("Table1[*]").length;

var heightTab = [];

var heightTabMax = 0;

for (var i=0; i<numTab ;i++){

    heightTab[i] = xfa.layout.h(xfa.resolveNode("Table1["+i+"]").Row2.COL_VAL, "cm");

    if (heightTab[i]>heightTab[i-1]){

        heightTabMax = heightTab[i];

    }

   

}

xfa.host.messageBox("heightTabMax: "+heightTabMax);

for (var j=0; j<numTab ;j++){

    xfa.resolveNode("Table1["+j+"]").Row2.COL_VAL.h = heightTabMax + "cm";

    xfa.host.messageBox("h: "+xfa.resolveNode("Table1["+j+"]").Row2.COL_VAL.h);

}

The only instruction that does not work on my Javascript code is the assignment of the recovered height or the following line:

xfa.resolveNode("Table1["+j+"]").Row2.COL_VAL.h = heightTabMax + "cm";

the value printed with the instruction xfa.host.messageBox("h: "+xfa.resolveNode("Table1["+j+"]").Row2.COL_VAL.h) is correct but in preview pdf I do not see the desired result but I see this:

Can you help me find the solution to this problem?

Thank you,

Francesca

このトピックへの返信は締め切られました。
ベストアンサー Magus069

It is possible to have tables next to each other within a "Flowed" content, right under the Content drop down, there's the "Flow Direction" option and if you select "Western Text" option, it will allow items to place automatically next to each other instead of "Top to Bottom".

19 の返信

Magus069
Level 10
November 1, 2019

Hi there,

I don't think setting the height for each field in a loop is the best method...

You might want to create a field which will contain the highest value and then set each of them individually within the layout:ready or initialize event...

But beware, this is not recommended, because as soon as you control the height of the fields based on multiple fields, an issue will be created. When you assign a height to a field and then the field with the highest height is reduced, all the fields will stay as you initially set it as the highest because their height are never reduced.. so technically it will never reduce and only go higher.

radzmar
Level 10
November 2, 2019

Much easier would be to use just one table with 3 colums instead of 3 separate table. In that case. you wouldn't need any scripting att all.

Level 2
November 4, 2019

Hi radzmar.

Unfortunately I cannot use a single table with 3 columns because the columns are not fixed but there will be as many as there will be in the xml. As explained, the table is created dynamically based on a data connection, which is why I created a table repeatable n times for the n columns in the xml. Would you have a better solution to suggest me?

Level 2
November 4, 2019

Hi Magus069,

could you please explain me better the solution you suggested?

What do you mean by "creating a field that will contain the highest value and then set each one individually"? Would you give me a practical example based on my form?

Thank you.

Magus069
Level 10
November 5, 2019

Well first, let's see if your code is working well... try using the relayout method at the end of your code.

if not, then maybe you will need another approach

Level 2
November 6, 2019

Thanks Magus069 for your advice.

I had made some attempts before your answer and managed to solve the problem by entering the code for the assignment of the height in the doc: ready event. In this event, the code works. However, having never used it in your opinion is a good approach? or could I have problems?

Magus069
Level 10
November 6, 2019

If it works without the relayout method, it's better this way...

On my first response to you, I did not consider the fact that the data you input within the tables is imported...

The issue where cells can't have their height reduced is usually triggered when the user can change the values within the cell, (only when you try to keep the highest height of the fields within a row)

however if the data imported in the tables is static and cannot be changed, don't mind this issue.

Level 2
November 7, 2019

Ok Magus069, thank you for your support.

I have another problem: I need to repeat the tableHeader in the other pages but I can't use the native property of the designer "include header row in subsequent pages" because I can't set the "repeat row for each data item".
Would you have any alternative solution to suggest? I had thought of transferring this table to the master page but I noticed that I can't make the subforms repeatable on these special pages

Help me again, please.....

This is the structure of my form:

Magus069
Level 10
November 8, 2019

Not sure if you'd encounter some issue for trying this, but your best bet would be having the header table part of your Master Page just outside of the Content Area so it appears on every page...

Level 2
November 13, 2019

I had thought of the same solution but in my case I can't adopt it because the table header does not have the number of fixed columns but can have n, based on those defined in the xml and to do this, I set the repeatable table. This setting is not allowed in the master pages.
Do you think there may be alternative solutions or not?