Auto-update calculation field in expanding table when line is deleted?

cdavis236

13-09-2017

I have an expanding table that allows adding and deleting rows. There is a grand total cell that accurately calculates the total. The issue is that, when I delete a row, the grand total does not update unless I make a change to one of the applicable cells in the remaining rows. How do I set my Grand Total cell to automatically recalculate when the Delete Line button is clicked?

Accepted Solutions (1)

Accepted Solutions (1)

mouslander

22-09-2017

So as we discussed offline your code is good. The issue is that you are viewing the file with PDF X-Change. I have reached out to them and they have acknowledged that this is not working in their software. They claim it will be fixed in an update.

Answers (10)

Answers (10)

mouslander

19-09-2017

On the delete row button you will need to use a recalculate action. Use this below the delete code:

xfa.form.recalculate(1);

This will force a recalculation and should solve the problem

MinusZero

19-09-2017

Hi,

That is a strange one, I have done a few tests and it worked. What i can suggest is try to target the field location more directly like you would with this.resolveNode.

It is slightly different with formCalc.

Instead of

sum(PurchaseOrderTable.Row1[*].ExtendedCost[*])

try

sum(xfa.form.form1.#subform.PurchaseOrderTable.Row1[*].ExtendedCost[*])

1302422_pastedImage_0.png

cdavis236

19-09-2017

Hi MinusZero,


Thank you. I am not sure why mine does not automatically recalculate. As far as I can tell I have it set up properly. See below. Footer Total Script.PNG

It automatically recalculates when I add a line, but it does not when I delete a line.

MinusZero

14-09-2017

Hi,

The calculated sum should change as long as the code is correct and in the right place.

In the flowable tutorial the Sub Total field has sum(Table.Table1.Row1[*].amount[*]) in it's FormCalc calculate event. Calculate event code continually calculates as things change in the form. When you click a button to remove a row, the amount should change.

In this example, the amount is summed and added to the SubTotal. The * adds all items in the column. Code isnt needed in the delete row button in this instance. The code in the calculate event does it all for you.

1299267_pastedImage_0.png

cdavis236

14-09-2017

Hi MinusZero,

Thanks for your suggestion. I actually have a working expandable table with a calculated sum. The issue is, if I delete a line using my delete line button, the sum doesn't recalculate (and subtract the missing row's value) unless I then edit a remaining row. I've taken a look through Adobe's Tutorials, but I can't seem to find anything to address this issue.

Thank you!

MinusZero

13-09-2017

Not a difficult thing to do but i would suggest looking at Adobe's Tutorials, they gave me a great start into the world of LiveCycle.

Creating a Purchase Order Form - http://help.adobe.com/en_US/livecycle/9.0/lcdesigner_qs_poform.pdf

This one is what you after, you create a table with adding and removing rows with calculated amounts.

Creating a Purchase Order Form That Has a Flowable Layout - http://help.adobe.com/en_US/livecycle/9.0/lcdesigner_qs_poformflowable.pdf