Improve performance hit by layout:ready in nested repeatable subforms

arvindkumar7

21-11-2015

Hi,

I am having a form which has a performance issue due to script in layout:ready event for 3 of the fields and these are fired more often. These 3 fields require height adjustment during form runtime when one add/remove a repeatable subform. Form have 3 nested repeatable subforms, third nesting in second and second nesting in first. So when the form grows near to 1 page size or more, performance hitting starts. Even exiting a text fields take 3-4 seconds.

So I want an alternative approach to set heights of these 3 fields or code for height adjustment run only when any of the 6 Add/Remove buttons is clicked. Some time I have to click a button having xfa.layout.relayout(); under click event to correct layout.  I have attached two images for better understanding for hierarchy.

Thanks

Arvind

Hierarchy

Capture.PNG

Layout

Capture3.PNG

Accepted Solutions (0)

Answers (4)

Answers (4)

arvindkumar7

25-11-2015

HI Bruce,

Thanks for your reply, I tried this way on my form but sometime removing an instance messed up table lines. See belowCapture5.PNG.

However, I found a way to improve the efficiency to its best. I put the code under add and remove buttons to increase/decrease the parent subforms height by that of their child objects. It improved the efficiency very much,

Regards

Arvind

_Bruce_Robertson

MVP

23-11-2015

Hi Arvind,

You will probably have better performance using nested tables instead of nested subforms.  Nested tables will resize the adjacent cells automatically.  The exception is with your image field, but do you really want the image distorted ... I assume you have the image field set to "Scale image to fit rectangle".

Anyway, here's an example of using nested tables in a similar situation to yours, https://sites.google.com/site/livecycledesignercookbooks/home/NestedTables.pdf?attredirects=0&d=1 ... and distorts the image ... so there is only one layout:ready event instead of three.

Regards

Bruce

arvindkumar7

21-11-2015

Hi BR001,

The 3 fields that have code in layout:ready event should have height as that of their child subforms. So.

ImageField1,Cell1 (at bottom in hierarchy) in SF1_Container should have height determined by height of SF2_Container

Cell2 in SF2_Container.SF2 should have height determined by height of SF3_Container


ex. If I add 3 instances of SF3 (say height 25pt) then Cell2  in SF2_Container.SF2 and also ImageField1,Cell1 in SF1_Container should be of height 25*3= 75pts

Similarly, If I add 4 instances of SF2 (say height 25pt) then ImageField1,Cell1 in SF1_Container should be of height 25*4= 100pts


The actual code is as given below for Cell2


form1.Subform1.Table1.Row1.Subform1.SF2_Container.SF2.Cell2::ready:layout - (JavaScript, client)

var heightField = xfa.layout.h(this.parent.SF3_Container, "pt");

this.h = heightField + "pt";

See below image.

Capture4.PNG

Hope this clears.

Regards

Arvind

_Bruce_Robertson

MVP

21-11-2015

Hi,

Can you explain the height calculation, is it something that can be calculated before adding the row or do you need to layout to complete to adjust the height calculation?

Regards

Bruce