Expand my Community achievements bar.

Add / Delete a row in a table without using a button

Avatar

Level 1

Hi,

I was just wondering if it was possible to remove or add a row in a table without using the button?  I noticed that in all examples, it always involve putting code in the button click event but I wanted to add or delete a row in a table based on the fact if the row contains a certain value or not.  Is that possible?

Much appreciated,

Vincent

3 Replies

Avatar

Level 10

Adding and removing rows in a table is based on the code and not on the Button. So you can place the same code to add/ remove rows in any other event. Like for example, you can place it in an exit event of the last field in the row (or) enter event of the first field in the row.

Hope this helps.

Thanks

Srini

Avatar

Level 1

Hi Srini,

I have tried that but for some reason every time I try to reference the index on the table, the value is 0.

For example I have a table with 3 rows in it. If I go, xfa.host.messageBox("" + Main.Subform1.Table1.Row2.index), the returned value is always 0.

Vincent

Avatar

Level 10

Vincent,

     Here is the updated file..

https://acrobat.com/#d=bVDBNM0pnS2IpfE58V01Tg

You have checked the checkbox "Repeat subform for each Row" for Header Row under IndTable1. You need to do at Row1 level of Table1.

I bound the Row1 of Table1 to <Row1> tag in your XML which can repeat multiple times.

I wrote the code in the Doc Ready event of the Test1 field to check whether the value is existing or not. If it does not have a value, then I am removing the instance of the Row1 by passing the current index.. (You can check the code)..

While creating a data connection using XML you need to make sure that the below structure is repeated atleast 2 times. And while previewing you can use make a copy of this same XML and remove Row1.

  <Row1>
    <Test1>Individual Name 1</Test1>
  </Row1>

Thanks

Srini