Remove instance of row in section

peartreeco

11-06-2015

I have tried everything that I can think of to get the Remove Instance button to work to remove the CURRENT instance but I can't figure it out.

Basically I have a table with a section.  Within this section I have one row that the user can add more instances of. I added a remove instance button but it acts erratically and I can't get it to remove the CURRENT instance. Sometimes it deletes the first instance..sometimes the last instance in the repeating section...it's all over the place and I can't figure out why.

Code for Remove instance button: 

this.resolveNode('PackageSection._ItemRow').removeInstance(this.parent.index);

if (xfa.host.version < 😎 {

  xfa.form.recalculate(1);

}

Hierarchy for table:

Page1>

   Column2Subform>

         Table1>

              PackageSection>

                               ItemRow (this has a cell subform with the add/remove instance buttons)

Any guidance would be appreciated.  Link to actual form:  Untitled3Sample.pdf

Accepted Solutions (1)

Accepted Solutions (1)

alcdtrainer1

11-06-2015

Use the following script on the click event of - button:

topmostSubform.Page1top.Column2.Table1.PackageSection._ItemRow.removeInstance(this.parent.parent.index);

Hope this hleps.

Thanks

Answers (3)

Answers (3)

peartreeco

12-06-2015

I found a workaround. My problem occurred when I added another instance of the table section.   The code for add/remove instances would work on the first section but not on subsequent instances.

I decided to split the table..convert my header row to a standalone textfield and the repeatable row into a one row table.  Then I wrapped the table and textfield in a subform to create my table 'section.'  All codes for removing/adding instances work as they should now.

peartreeco

12-06-2015

Thanks so much, but it's not working still.  That's the problem that I am having..the code is ok and it works for the first instance of the table section. But if I add more instances of the table sections the buttons don't work at all. I suspect it has something to do with the form construction or another setting and not so much with the script

alcdtrainer1

15-06-2015

Just FYI, The form is working as expected when i downloaded your form and added the suggested script. Not sure why it is not working for you. Anyways, if your workaround is working Cheers ! Thanks