Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

SOLVED

need a better way to reset selected cells in a table

Avatar

Level 2

Hello all,

I have been looking at the various threads discussing resetting only selected fields in a form and leaving others unchanged.

The form I am working on has a table of 20 body rows with 8 columns. I want to have a reset button that resets 6 of the cells in each row.

I am using the following snippet:

for (var nRow = 1; nRow < 21; nRow++)

for (var nCell = 0; nCell < 6; i++)

{

xfa.host.resetData("form1.page1.wrapper.ICC.Table1.Row[" + nRow + "].rate[" + nCell + "]");

  }

This works but is extremely slow (on the order of 10 seconds) and my pc is no slouch.  There has to be a simpler (and faster!) way to do this.

I saw one thread where the cells that were to be spared from the reset could be listed but just could not make that work at all. I thought about putting the cells to be spared into a subform but that went nowhere, as I was only able to place individual cells into separate subforms.

Any suggestions will be welcome ... with formcalc script if possible:)

Thanks.

Harry Ohm.

edit: Now it appears it does not work as I first thought. It works on a single row but not when the nested for loops are used.

Message was edited by: HarryOhm

1 Accepted Solution

Avatar

Correct answer by
Level 10

Hi Harry,

Just two small issues. I would wrap the first for loop in {} and then you have i++ in the second loop:

for (var nRow = 1; nRow < 21; nRow++)

{

     for (var nCell = 0; nCell < 6; nCell++)

     {

          xfa.host.resetData("form1.page1.wrapper.ICC.Table1.Row[" + nRow + "].rate[" + nCell + "]");

     }

}

It looks like your table is static (rows do not repeat). One option would be to build up a variable/string with the objects names and then reset that. This is a reset example from one of our forms (http://assure.ly/gBJYj9). Here it is resetting one row and two fields outside of the table:

// reset page 6 only

var f1 = Table1.Row1.description.somExpression + ", ";

var f2 = f1 + Table1.Row1.quantity.somExpression + ", ";

var f3 = f2 + Table1.Row1.unitPrice.somExpression + ", ";

var f4 = f3 + positionedSF.myName.somExpression + ", ";

var f5 = f4 + positionedSF.myAddress.somExpression;

xfa.host.resetData(f5);

Hope that helps,

Niall

Assure Dynamics

View solution in original post

2 Replies

Avatar

Correct answer by
Level 10

Hi Harry,

Just two small issues. I would wrap the first for loop in {} and then you have i++ in the second loop:

for (var nRow = 1; nRow < 21; nRow++)

{

     for (var nCell = 0; nCell < 6; nCell++)

     {

          xfa.host.resetData("form1.page1.wrapper.ICC.Table1.Row[" + nRow + "].rate[" + nCell + "]");

     }

}

It looks like your table is static (rows do not repeat). One option would be to build up a variable/string with the objects names and then reset that. This is a reset example from one of our forms (http://assure.ly/gBJYj9). Here it is resetting one row and two fields outside of the table:

// reset page 6 only

var f1 = Table1.Row1.description.somExpression + ", ";

var f2 = f1 + Table1.Row1.quantity.somExpression + ", ";

var f3 = f2 + Table1.Row1.unitPrice.somExpression + ", ";

var f4 = f3 + positionedSF.myName.somExpression + ", ";

var f5 = f4 + positionedSF.myAddress.somExpression;

xfa.host.resetData(f5);

Hope that helps,

Niall

Assure Dynamics

Avatar

Level 2

Niall,

Many thanks for your reply.

That works much better. Seems to be a liitle speedier.

Harry.