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

SOLVED

Remove instance of row in section

peartreeco
Level 2
Level 2

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

1 Accepted Solution
Correct answer by
Anonymous
Not applicable

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

View solution in original post

4 Replies
Correct answer by
Anonymous
Not applicable

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

View solution in original post

peartreeco
Level 2
Level 2

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

peartreeco
Level 2
Level 2

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.

Anonymous
Not applicable

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