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

Adding and deleting rows in multiple tables and copying data

dominicc4139063
Level 1
Level 1

Hello,

I have a document that I would like to have expanding tables. I have been able to use a button to add an instance of a row to 2 different tables as well as delete a row from both tables simultaneously. I would like to however, also allow the second table to be repeated with the same extra rows that are in the first. And then be able to delete the same rows in every column.

I also cannot figure out how to have the same data in each of the tables. I am only needing 1 field out of the first table to be entered into the rest of the tables.

This is sort of a representation of what I would like to do. the first table should be able to add rows which will then add rows to the other 2 tables with the same information in the first cell. Then, the second two tables should have the ability to be repeated and still contain the same data.

NameInfoInfo2Header 4Header 5

Entry1

Entry2
NameHeader 2Header 3
Entry1
Entry2
NameHeader 2Header 3
Entry1
Entry2

I know this is a lot to ask and I appreciate anyone's help.

If there is any other information that I need to give you please let me know and I will get it on here ASAP!

Thank you!!!

1 Accepted Solution
_Bruce_Robertson
Correct answer by
Level 10
Level 10

Hi Dom,

To get the "Add Client" button working, replace the existing code with this;

var attorneyInfo = form1.Main.Clients.AttorneyInfo.instanceManager.addInstance();

attorneyInfo.ClientTable._WitnessInfo.setInstances(DeponentInfo.DeponentTable._WitnessInfo.count);

The second line sets the number of instances to match the number of witnesses that have been added.

The delete code should be using delNum in all the calls to removeInstance, tryl

var delNum = this.parent.parent.index;

for (var i = 0; i < Clients._AttorneyInfo.count; i++)

{

    var client = xfa.resolveNode("form1.Main.Clients.AttorneyInfo[" + i + "]");

    client.ClientTable.WitnessInfo.instanceManager.removeInstance(delNum);

}

this.parent.parent.instanceManager.removeInstance(delNum);

Regards

Bruce

View solution in original post

8 Replies
_Bruce_Robertson
Level 10
Level 10

Hi,

I think you should be able to do what you want with some code in the calculate event of the Name cell of the second tables, something like this JavaScript;

xfa.resolveNode("Table1.Row1[" + Row1.index + "].TextField1").rawValue;

This assumes the first table is called Table1 with the repeating row called Row1 and the second table also with a repeating row called Row1 and the column called TextField1.

If you need more help, maybe post a link to a sample of your form and we can refer to the correct fields.

Bruce

dominicc4139063
Level 1
Level 1

Ok so this works. However, I can only get it to add rows to the first instance of the second table. I need it to add rows to all of the instances of the second table. I also need to be able to click a button to remove a certain row from all instances of the second table as well as the first. The first table has a row that repeats, the second table has a row that repeats and the entire table needs to repeat. So, I am very appreciative of your answer and you have helped me get further in this form, Thank you.

Also, how could I post a link to the form?

I'm running Acrobat 9 Pro

and Livecycle ES version 8.2.1.3144.1.471865

_Bruce_Robertson
Level 10
Level 10

Hi,

To post a link to your form you will have to upload it to a file sharing site, link Google Docs, OneDrive, dropbox, etc and post a link to it in this thread.

Regards

Bruce

dominicc4139063
Level 1
Level 1

Ok, I thought there might be a different way to upload it on here. I have uploaded it to dropbox but when I view it, it gives me a message saying that I need to upgrade my adobe reader.

Anyways, here is the link. Hope you can view it. And thank you for your help!

https://www.dropbox.com/s/yefh80pb6eiq1u4/Job%20Productionform.pdf?dl=0

_Bruce_Robertson
Level 10
Level 10

Hi,

To loop though the second table adding rows to the sub-table use some code like;

for (var i = 0; i < Clients._AttorneyInfo.count; i++)

{

var client = xfa.resolveNode("form1.Main.Clients.AttorneyInfo[" + i + "]");

client.ClientTable.WitnessInfo.instanceManager.addInstance();

}

I've updated your sample to check the above code

https://sites.google.com/site/livecycledesignercookbooks/home/Job%20Productionform.updated.pdf?attre...

The delete button would be similar but you would use the _AttorneyInfo.index as a parameter to the removeInstance() method

Regards

Bruce

dominicc4139063
Level 1
Level 1

This works great! However, I do see that all of the secondary tables have to be added before I add a new witness. Is there anywhere that I can move the code so that a new row is automatically added to any new secondary tables that the user adds?

Also, I am trying to put together the code to remove the rows but it does not seem to be working. This is what I've done which I think is what you were trying to tell me to do.

var delNum = this.parent.parent.index;

//form1.Main.Clients.AttorneyInfo.ClientTable.WitnessInfo.instanceManager.removeInstance(delNum);

for (var i = 0; i < Clients._AttorneyInfo.index; i++)

{

    var client = xfa.resolveNode("form1.Main.Clients.AttorneyInfo[" + i + "]");

    client.ClientTable.WitnessInfo.instanceManager.removeInstance(i);

}

this.parent.parent.instanceManager.removeInstance(delNum);

Again, Thank you sooo much for your time and your help it is greatly appreciated!

-Dom

_Bruce_Robertson
Correct answer by
Level 10
Level 10

Hi Dom,

To get the "Add Client" button working, replace the existing code with this;

var attorneyInfo = form1.Main.Clients.AttorneyInfo.instanceManager.addInstance();

attorneyInfo.ClientTable._WitnessInfo.setInstances(DeponentInfo.DeponentTable._WitnessInfo.count);

The second line sets the number of instances to match the number of witnesses that have been added.

The delete code should be using delNum in all the calls to removeInstance, tryl

var delNum = this.parent.parent.index;

for (var i = 0; i < Clients._AttorneyInfo.count; i++)

{

    var client = xfa.resolveNode("form1.Main.Clients.AttorneyInfo[" + i + "]");

    client.ClientTable.WitnessInfo.instanceManager.removeInstance(delNum);

}

this.parent.parent.instanceManager.removeInstance(delNum);

Regards

Bruce

View solution in original post

dominicc4139063
Level 1
Level 1

Thank you so much this works wonderfully!!!