I have very simple code. On click of the button Add you can add unlimited # of instances. On click of the button remove, you remove instance. Works fine, removes all instances, but when you click Add button again, it adds first instance with the data you have entered before. It does not clean data from the first instance. Does anyone have any suggestion please. How do you clean data from the last instance before removeing it?
some code
.
.
.
.
}
else
{
Sub1.Sub2._Sub3.removeInstance(this.parent.parent.parent.parent.index);
}
xfa.layout.relayout();
Solved! Go to Solution.
Views
Replies
Total Likes
If you observe the code I sent you earlier, I was passing the index of the subform that needs to be cleared.
But there is one issue with the above code: instead of Square brackets, I had placed regular bracket.
var intIndex = this.parent.parent.parent.parent.index; //identify the index of the subform instance you want to delete data from.
xfa.host.resetData("Sub1.Sub2.Sub3[" + intIndex + "]");
Thanks
Srini
Views
Replies
Total Likes
The removeInstance should remove the data in all the fields in the Subform along with deleting the Subform from the form.
Probably try commenting the xfa.layout.relayout() line in the code.
To delete the data in all the fields within the subform, you can use:
xfa.host.resetData("Sub1.Sub2.Sub3(" + this.parent.parent.parent.parent.index + ")");
If you still have issues, probably sharing the document might help.
Thanks
Srini
Message was edited by: Srini Dhulipalla
Views
Replies
Total Likes
Thanks Srini. The problem is that the code above will remove data for all added instances. If I add 5 instances, with the code above, if I want to delete instance 4 and delete all that for instance 4, it will wipe out all data for all instances above, not just the instance 4.
I need a code that will clean all the fields for the individual instance before removing it. resetData() does not work as it cleans all instances.
Views
Replies
Total Likes
If you observe the code I sent you earlier, I was passing the index of the subform that needs to be cleared.
But there is one issue with the above code: instead of Square brackets, I had placed regular bracket.
var intIndex = this.parent.parent.parent.parent.index; //identify the index of the subform instance you want to delete data from.
xfa.host.resetData("Sub1.Sub2.Sub3[" + intIndex + "]");
Thanks
Srini
Views
Replies
Total Likes
Thanks Srini. It works now. I used your code and make some additional changes to the subforms I was referencing.
Views
Replies
Total Likes
Views
Likes
Replies