Expand my Community achievements bar.

SOLVED

moveInstance not moving the subforms

Avatar

Former Community Member

1.JPG


I having 2 subforms named Subform3[0], Subform3[1] and three buttons.

Button 1 : Add - to add new subform based to the parent subform Subform3[0].
Button2 : "Move index 1 to index 0" - to move subform3[0] to subform3[1].
button 2: "Move index 2 to index 0" - to move subform3[2] to subform3[0].

if i add a new subform,

and press the button 2,i am able to switch the subform3[0]
and subform3[1]( newly created subform based to subform3[0].

but, if i press the button 2, i am not able to swith the subform3[2] position to subform3[0] position .

The script is stop working.

please suggest what is the best approach to overcome this issue.

Script in butoon 1


var subform="Subform3[" + 0 + "]";
var osubform=xfa.resolveNode(subform);


osubform.instanceManager.addInstance(1);
xfa.host.setFocus(osubform.TextField1);

xfa.form.recalculate(1);


Here is the scripts used in Button 2:

xfa.form.recalculate(1);

var From="Subform3[" + 1 + "]" ;
var nFrom=xfa.resolveNode(From);

var To="Subform3[" + 0 + "]" ;
var nTo=xfa.resolveNode(To);

nFrom=nFrom.index; //1
nTo=nTo.index; // 0

xfa.host.messageBox( " nFrom : " + nFrom);
xfa.host.messageBox( "nTo : " + nTo);

Subform3.instanceManager.moveInstance(nFrom,nTo);


Here is the scripts used in Button 3:

xfa.form.recalculate(1);

var From="Subform3[" + 2 + "]" ;
var nFrom=xfa.resolveNode(First);

var To="Subform3[" + 0 + "]" ;
var nTo=xfa.resolveNode(Second);

nFirst=nFirst.index;
nTo=nSecond.index;

Subform3.instanceManager.moveInstance(nFrom,nTo);

here is the link to the XDP :

https://acrobat.com/#d=97DB07WSHVndBtA18FiW4A

1 Accepted Solution

Avatar

Correct answer by
Level 10

Hi,

I just think that it is a bad idea to have two repeating subforms with the same name. There is a potential for a conflict in the instance numbers of the various instances of both subforms.

Here we have an example of a table with two repeating rows (the first one is controlled from the dropdown, while the second has an add row button). These repeating rows have different names, so that they can be controlled separately.

https://acrobat.com/#d=khu3Ik*9LUz60afNWuCUsA

Hope that helps,

Niall

View solution in original post

1 Reply

Avatar

Correct answer by
Level 10

Hi,

I just think that it is a bad idea to have two repeating subforms with the same name. There is a potential for a conflict in the instance numbers of the various instances of both subforms.

Here we have an example of a table with two repeating rows (the first one is controlled from the dropdown, while the second has an add row button). These repeating rows have different names, so that they can be controlled separately.

https://acrobat.com/#d=khu3Ik*9LUz60afNWuCUsA

Hope that helps,

Niall