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
BedrockMission!

Learn More

View all

Sign in to view all badges

Reset Dynamic Form with multiple tables

Avatar

Avatar
Validate 1
Level 2
DiveMasterTx
Level 2

Likes

2 likes

Total Posts

16 posts

Correct Reply

2 solutions
Top badges earned
Validate 1
Boost 1
Applaud 5
Affirm 1
View profile

Avatar
Validate 1
Level 2
DiveMasterTx
Level 2

Likes

2 likes

Total Posts

16 posts

Correct Reply

2 solutions
Top badges earned
Validate 1
Boost 1
Applaud 5
Affirm 1
View profile
DiveMasterTx
Level 2

27-12-2018

I have a form to build flowable dynamic lesson plans for training.  Each lesson plan form consists of multiple pages, some of the pages contain multiple subforms, several having dynamic table rows.  I am attempting to place a single reset form button on the page to clear all field values and reset all table row instances to 1 by clicking a button on the form master page. 

My Current XFA/javascript attempt is below;

LP.#pageSet[0].Pt1.sFrmPfHd.resetForm::click - (JavaScript, client)
  xfa.host.resetData();
//  xfa.host.remerge(); <- didn't work
// loop through table and delete rows
while (LP.Pg1.FlowContentPg1.rowSFrmTngMethodPick.tblData._rowSubform.count > 1)
{
  LP.Pg1.FlowContentPg1.rowSFrmTngMethodPick.tblData._rowSubform.removeInstance(0);
}
while (LP.Pg1.FlowContentPg1.rowSFrmTngMethodsFree.tblData._rowSubform.count > 1)
{
  LP.Pg1.FlowContentPg1.rowSFrmTngMethodsFree.tblData._rowSubform.removeInstance(0);
}
while (LP.Pg3.PgBody.rowSFrmTngMethodPick.tblData._rowSubform.count > 1)
{
  LP.Pg3.PgBody.rowSFrmTngMethodPick.tblData._rowSubform.removeInstance(0);
}
while (LP.Pg3.PgBody.rowSFrmTngMethodsFree.tblData._rowSubform.count > 1)
{
  LP.Pg3.PgBody.rowSFrmTngMethodsFree.tblData._rowSubform.removeInstance(0);
}
while (LP.Pg3.PgBody.rowSFrmLP.tblData._rowSubform.count > 1)
{
  LP.Pg3.PgBody.rowSFrmLP.tblData._rowSubform.removeInstance(0);
}

I would attach the form but cannot seem to find that as an option.  If you would like to see  the actual form please email me.

mailto:toby.yadon@us.af.mil

Accepted Solutions (1)

Accepted Solutions (1)

Avatar

Avatar
Coach
MVP
radzmar
MVP

Likes

395 likes

Total Posts

2,686 posts

Correct Reply

491 solutions
Top badges earned
Coach
Ignite 3
Ignite 1
Validate 1
Give Back 50
View profile

Avatar
Coach
MVP
radzmar
MVP

Likes

395 likes

Total Posts

2,686 posts

Correct Reply

491 solutions
Top badges earned
Coach
Ignite 3
Ignite 1
Validate 1
Give Back 50
View profile
radzmar
MVP

29-12-2018

This should do the trick.

// Reset subforms to inital number of occurences

function resetSubforms (oNode) {

    if (oNode.className === "subform") {

    if (oNode.instanceManager !== null) {

    var iCount = oNode.instanceManager.count,

    iMin = oNode.occur.min ? oNode.occur.min : 1,

    iInit = oNode.occur.initial ? oNode.occur.initial : iMin;

    if (iCount > iInit) {

    oNode.instanceManager.setInstances(iInit);

    }

    }

    }

    for (var i = 0; i < oNode.nodes.length; i += 1) {

        resetSubforms (oNode.nodes.item(i));

    }

}

resetSubforms (xfa.form); // call the function

Answers (2)

Answers (2)

Avatar

Avatar
Validate 1
Level 2
DiveMasterTx
Level 2

Likes

2 likes

Total Posts

16 posts

Correct Reply

2 solutions
Top badges earned
Validate 1
Boost 1
Applaud 5
Affirm 1
View profile

Avatar
Validate 1
Level 2
DiveMasterTx
Level 2

Likes

2 likes

Total Posts

16 posts

Correct Reply

2 solutions
Top badges earned
Validate 1
Boost 1
Applaud 5
Affirm 1
View profile
DiveMasterTx
Level 2

28-12-2018

I tried your suggestion and was unable to make it work.  I may not be addressing the dynamic node addresses quite the way I need to.  Would it be possible to write a generic loop to loop through the node tree and reset all setInstances(1) without having to specify them individually?  This would also make the function usefule in a multitude of forms...

Thank you for your time.

Avatar

Avatar
Coach
MVP
radzmar
MVP

Likes

395 likes

Total Posts

2,686 posts

Correct Reply

491 solutions
Top badges earned
Coach
Ignite 3
Ignite 1
Validate 1
Give Back 50
View profile

Avatar
Coach
MVP
radzmar
MVP

Likes

395 likes

Total Posts

2,686 posts

Correct Reply

491 solutions
Top badges earned
Coach
Ignite 3
Ignite 1
Validate 1
Give Back 50
View profile
radzmar
MVP

28-12-2018

You should use the setInstances() method first to reset the table to the desired amount of rows.

Then use the resetData() method.

// Reset tables

LP.Pg1.FlowContentPg1.rowSFrmTngMethodPick.tblData._rowSubform.setInstances(1);

LP.Pg1.FlowContentPg1.rowSFrmTngMethodsFree.tblData._rowSubform.setInstances(1);

// reset data

xfa.host.resetData();