Expand my Community achievements bar.

Adobe Livecycle Designer row height issue

Avatar

Level 1

I have table within another table and I need to adjust Table Row Height relatively to the row height of main table.

According to documentation I've got a row height of the main table using:

 

var mainRowHeight = xfa.layout.h(parent.parent.parent, "in");

 

after that I made some calculations with this value and trying to adjust element height using calculated value:

 

 

var calculatedValue = mainRowHeight / 2;//just for example 

this.h = calculatedValue + "in";

 

and nothing happens. However if I just use any other variable height is being adjusted without any issue:

 

var newHeight = 1.5;

this.h = newHeight + "in"; //this way works perfectly 

 

I tried to convert it to string and to float and vice versa and nothing helps.

how can I adjust value returned from xfa.layout.h() in order to use it for setting height of another element?

6 Replies

Avatar

Level 7

Hi @DmytroVe ,

 

It seems like the issue could be due to the return type or precision of xfa.layout.h(...). While it returns a numeric value, sometimes it may be returned as a string or as a float with hidden metadata that LiveCycle doesn’t handle well when doing math on it directly.

 

Fixes to Try:

1) Force the value to a float explicitly before calculation:

var mainRowHeight = parseFloat(xfa.layout.h(parent.parent.parent, "in"));
var calculatedValue = mainRowHeight / 2;
this.h = calculatedValue + "in";

 

2) Check for undefined or null:

If xfa.layout.h(...) returns undefined or NaN due to layout not being ready or context being incorrect, it won’t work in calculations.

 

3) Delay the script:

Sometimes xfa.layout.h(...) is not available at the time the script runs. Try placing this logic in an event like layout:ready or calculate.

 

Also, do accept the solution if any of fixes worked for you so that anyone else also facing something similar can directly go to the right response.

 

Thanks

Avatar

Level 1

Thanks for reply,

I tried to put 

parseFloat(xfa.layout.h(parent.parent.parent, "in"));

but it didn't help (value is calculated but height is not being adjusted )

1000001772.png

However if I put parseFloat( "2.3" ); like in line 4

1000001769.png

height is being adjusted correctly:

1000001771.png

Avatar

Level 7

Hi @DmytroVe ,

 

Please validate with suggested 2nd and 3rd point as well.

Avatar

Level 1

Hi @AnkitJasani29 ,

 

2: value is being calculated correctly at line 5, so it is definitely not undefined nor NaN

 

3: I tried in calculation, layout: ready, form: ready, neither of them are functioning properly anytime I use layout.h value

 

Thanks 

Avatar

Level 7

Hi @DmytroVe ,

 

Try creating an intermediate hard-coded variable manually — LiveCycle needs to freeze the value.

 

var mainRowHeight = parseFloat(xfa.layout.h(parent.parent.parent, "in"));
var stableHeight = +mainRowHeight; // <-- force primitive value
var calculatedValue = stableHeight / 2;
this.h = calculatedValue + "in";

 

Notice the +mainRowHeight — this forces LiveCycle to treat it as a simple primitive number.

Alternatively, you can also stringify and re-parse:

 

var stableHeight = parseFloat("" + xfa.layout.h(parent.parent.parent, "in"));

 

 

Avatar

Community Advisor

Hi @DmytroVe ,

1. Force Primitive Type Handling: First, make sure the value you get from xfa.layout.h() is treated as a pure number and not a complex object.

2. Ensure Proper Timing: Ensure that the layout is fully ready when you execute your script. If the layout is not ready, the xfa.layout.h() value may not be accessible yet.

3. Check for No Conflicts: Sometimes, LiveCycle might not update the height dynamically unless explicitly forced to, so we need to directly manipulate the height in a way that LiveCycle expects.

// Ensure the layout value is accessible and treated as a primitive number
var mainRowHeight = parseFloat(xfa.layout.h(parent.parent.parent, "in")); 

// Ensure it's a valid number
if (!isNaN(mainRowHeight)) {
    // Force a clean primitive value (important for LiveCycle)
    var stableHeight = +mainRowHeight; 

    // Perform your calculation
    var calculatedValue = stableHeight / 2; // Adjust as needed

    // Set the height of the element
    this.h = calculatedValue + "in";
} else {
    // Handle error or fallback if value is invalid
    console.log("Error: Invalid main row height");
}

Key Points in This Solution:

  - parseFloat ensures that you're working with a numeric value (no hidden strings).

+mainRowHeight forces the value into a primitive number format, which LiveCycle handles more reliably.

  - Error Handling (isNaN): Ensures that you're only proceeding if the xfa.layout.h() value is valid.

Direct Height Assignment: By directly assigning the calculated value to this.h, we’re explicitly updating the height.

Timing Considerations:

If this still doesn't work as expected, try the following:

Use Event Handlers: Place the script inside the layout:ready or form:ready event to ensure everything is initialized.

this.layout.ready = function() {
    // Place the same script here
};


Regards,
Amit