Avg. Rating 4.5

Problem

In a dynamic form rows can be added and deleted from a table, but if there is a calculated sequence number then all rows may need to be recalculated depending on where the row was inserted or deleted.

Solution

Using the XFA form dependency tracking for calculate event scripts we can easily recalculate the sequence number with two lines of JavaScript.

Detailed explanation

In the calculate event of cell in the table we can add the following code;

var count = _detail.count;
detail.index + 1;

The purpose of the first line " var count = _detail.count; " is to add _detail.count to the dependency list for this calculation event, as we don't actually use this value in the script. This means that whenever a row is added or removed all the calculate events on all the rows will fire, generating the correct sequence number if a row is deleted in the middle..

The _detail field (with the underscore) is another way of referencing the detail instanceManager , I could have written this line of code as " var count = detail.instanceManager.count; " and in this case it doesn't really matter but generally I use the underscore syntax as it works even when there are no rows.

LiveCycle Designer Forms support XSLT 1.0 and in this sample is an example of using XSLT to generate an alphabetic sequence and a roman number sequence.

 

In a dynamic form rows can be added and deleted from a table, but if there is a calculated sequence number then all rows may need to be recalculated depending on where the row was inserted or deleted.


+
This work is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 Unported License. Permissions beyond the scope of this license, pertaining to the examples of code included within this work are available at Adobe.

Report abuse

Related recipes