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

copying nested table contents

Avatar

Avatar
Validate 1
Level 1
martynd4832568
Level 1

Likes

2 likes

Total Posts

14 posts

Correct Reply

0 solutions
Top badges earned
Validate 1
Boost 1
Applaud 5
View profile

Avatar
Validate 1
Level 1
martynd4832568
Level 1

Likes

2 likes

Total Posts

14 posts

Correct Reply

0 solutions
Top badges earned
Validate 1
Boost 1
Applaud 5
View profile
martynd4832568
Level 1

05-11-2018

I need a little help here. I have an expanding table that has a nested (also expanding) table in it. The header row contains a user-entered project name. The nested table contains milestones for each project. I have a button used to move the completed project to an Archive page. Currently, I have the button executing 3 tasks:

1.     Add a new section to the Archive table

2.     Copy the contents of the Project table to the Archive table

3.     Delete the contents from the Projects table.

I can add a section to the Archive table, but it only copies the first line - the subsequent expanded lines are ignored.

I have been through the previous questions on this topic, but although similar, I cannot get them to work for me.

So, I need to add this:

1614769_pastedImage_1.png

to this

1614776_pastedImage_2.png

I have this code on the Click event of the green Archive button:

form1.Archive_Page.Table1.Row1.instanceManager.addInstance();

xfa.form.recalculate(true);

I have also included the hierarchy

1614777_pastedImage_3.png

Any help greatly appreciated by this newbie!  Using LC ES 4 on Windows 10.

Accepted Solutions (0)

Answers (6)

Answers (6)

Avatar

Avatar
Validate 1
Level 1
martynd4832568
Level 1

Likes

2 likes

Total Posts

14 posts

Correct Reply

0 solutions
Top badges earned
Validate 1
Boost 1
Applaud 5
View profile

Avatar
Validate 1
Level 1
martynd4832568
Level 1

Likes

2 likes

Total Posts

14 posts

Correct Reply

0 solutions
Top badges earned
Validate 1
Boost 1
Applaud 5
View profile
martynd4832568
Level 1

07-11-2018

Hi Radzmar

I copied over the code you supplied into the click event of the button, but nothing happens. Any suggestions as to what I do now? Really appreciate your help on this.

Avatar

Avatar
Validate 1
Level 4
MinusZero
Level 4

Likes

30 likes

Total Posts

326 posts

Correct Reply

54 solutions
Top badges earned
Validate 1
Boost 5
Boost 3
Boost 25
Boost 10
View profile

Avatar
Validate 1
Level 4
MinusZero
Level 4

Likes

30 likes

Total Posts

326 posts

Correct Reply

54 solutions
Top badges earned
Validate 1
Boost 5
Boost 3
Boost 25
Boost 10
View profile
MinusZero
Level 4

06-11-2018

Hi,

radzmar​'s solution would replace your code.

If you dont want to go down the often confusing route of 'for statements', what you have would be placed in a button click. If you want to do multiple rows at the same time, you will have to write that code in as well. I have done that before. If your subform is limited to the amount of rows that can be added, you only have to write a finite amount of code.

Avatar

Avatar
Validate 1
Level 1
martynd4832568
Level 1

Likes

2 likes

Total Posts

14 posts

Correct Reply

0 solutions
Top badges earned
Validate 1
Boost 1
Applaud 5
View profile

Avatar
Validate 1
Level 1
martynd4832568
Level 1

Likes

2 likes

Total Posts

14 posts

Correct Reply

0 solutions
Top badges earned
Validate 1
Boost 1
Applaud 5
View profile
martynd4832568
Level 1

06-11-2018

Many thanks for taking a look at this. As I said in my original post, I'm very much a newbie at this, so forgive a dumb question (or three!) - does this code REPLACE mine or is it in addition to it? I replaced it, but no joy. If it's in addition, where does it go?

I've just realized that I didn't post it. So here is my original work, broken down into the three steps:

form1.Main.Table1.Row1.Subform2.Table2.HeaderRow.Subform5.btn_Archive::click - (JavaScript, client)

// Step 1 - Add line to Archive page;

form1.Archive_Page.Table1.Row1.instanceManager.addInstance();

xfa.form.recalculate(true);

//Step 2 - Copy items to Archive Page

xfa.resolveNode("form1.Archive_Page.Table1.Row1.Subform2.Table2.HeaderRow[" + (form1.Archive_Page.Table1.Row1.Subform2.Table2.HeaderRow.instanceManager.count - 1) + "].Project_Desc").rawValue = xfa.resolveNode("form1.Main.Table1.Row1.Subform2.Table2.HeaderRow[" + this.parent.index + "].Project_Desc").rawValue;

xfa.resolveNode("form1.Archive_Page.Table1.Row1.Subform2.Table2.Row1[" + (form1.Archive_Page.Table1.Row1.Subform2.Table2.Row1.instanceManager.count - 1) + "].actionItem").rawValue = xfa.resolveNode("form1.Main.Table1.Row1.Subform2.Table2.Row1[" + this.parent.index + "].actionItem").rawValue;

xfa.resolveNode("form1.Archive_Page.Table1.Row1.Subform2.Table2.Row1[" + (form1.Archive_Page.Table1.Row1.Subform2.Table2.Row1.instanceManager.count - 1) + "].Owner").rawValue = xfa.resolveNode("form1.Main.Table1.Row1.Subform2.Table2.Row1[" + this.parent.index + "].Owner").rawValue;

xfa.resolveNode("form1.Archive_Page.Table1.Row1.Subform2.Table2.Row1[" + (form1.Archive_Page.Table1.Row1.Subform2.Table2.Row1.instanceManager.count - 1) + "].startDate").rawValue = xfa.resolveNode("form1.Main.Table1.Row1.Subform2.Table2.Row1[" + this.parent.index + "].startDate").rawValue;

xfa.resolveNode("form1.Archive_Page.Table1.Row1.Subform2.Table2.Row1[" + (form1.Archive_Page.Table1.Row1.Subform2.Table2.Row1.instanceManager.count - 1) + "].endDate").rawValue = xfa.resolveNode("form1.Main.Table1.Row1.Subform2.Table2.Row1[" + this.parent.index + "].endDate").rawValue;

xfa.resolveNode("form1.Archive_Page.Table1.Row1.Subform2.Table2.Row1[" + (form1.Archive_Page.Table1.Row1.Subform2.Table2.Row1.instanceManager.count - 1) + "].est_Hours").rawValue = xfa.resolveNode("form1.Main.Table1.Row1.Subform2.Table2.Row1[" + this.parent.index + "].est_Hours").rawValue;

//Step 3 - Removing copied items from first page  form1.Main.Table1.Row1.Subform2.Table2.Row1.actionItem     

//form1.form1.Main.Table1.Row1.Subform2.Table2.Row1.orderItem.instanceManager.removeInstance(this.parent.index); 

//xfa.form.recalculate(true);

Again, many thanks!

Avatar

Avatar
Coach
MVP
radzmar
MVP

Likes

394 likes

Total Posts

2,686 posts

Correct Reply

490 solutions
Top badges earned
Coach
Ignite 3
Ignite 1
Validate 1
Give Back 50
View profile

Avatar
Coach
MVP
radzmar
MVP

Likes

394 likes

Total Posts

2,686 posts

Correct Reply

490 solutions
Top badges earned
Coach
Ignite 3
Ignite 1
Validate 1
Give Back 50
View profile
radzmar
MVP

06-11-2018

If haven't had the time to build a nested table as yours but build a script from the hierarchy that should do the job.

var oRows = Table1.resolveNodes("Row1[*]"),

oSubRows,

oCopyTable = Archive_Page.Table1,

oCopyRows, oCopySubRows;

// Set same amount of rows in duplicated table

oTargetTable._Row1.setInstances(oRows.length);

oCopyRows = oCopyTable.resolveNodes("Row1[*]");

// Loop through source table rows

for (var i = 0; i < oRows.length; i += 1) {

     oSubRows = oRows.item(i).Subform2.Table2.resolveNodes("Row1[*]");

     // Set same amount of rows in nested table copy

     oCopyRows.item(i).Subform2.Table2._Row1.setInstances(oSubRows.length);

     oCopySubRows = oCopyRows.item(i).Subform2.Table2.resolveNodes("Row1[*]");

     // Loop through nested source table rows

     // Copy values from nested source to nested table copy

     for (var j = 0; j < oSubRows.length; j += 1) {

          oCopySubRows.item(j).actionItem.rawValue = oSubRows.item(j).actionItem.rawValue;

          oCopySubRows.item(j).Owner.rawValue = oSubRows.item(j).Owner.rawValue;

          // go on …

     }

}

Avatar

Avatar
Validate 1
Level 1
martynd4832568
Level 1

Likes

2 likes

Total Posts

14 posts

Correct Reply

0 solutions
Top badges earned
Validate 1
Boost 1
Applaud 5
View profile

Avatar
Validate 1
Level 1
martynd4832568
Level 1

Likes

2 likes

Total Posts

14 posts

Correct Reply

0 solutions
Top badges earned
Validate 1
Boost 1
Applaud 5
View profile
martynd4832568
Level 1

06-11-2018

Thanks for the input - as you say, nested tables are tricky!

Avatar

Avatar
Validate 1
Level 4
MinusZero
Level 4

Likes

30 likes

Total Posts

326 posts

Correct Reply

54 solutions
Top badges earned
Validate 1
Boost 5
Boost 3
Boost 25
Boost 10
View profile

Avatar
Validate 1
Level 4
MinusZero
Level 4

Likes

30 likes

Total Posts

326 posts

Correct Reply

54 solutions
Top badges earned
Validate 1
Boost 5
Boost 3
Boost 25
Boost 10
View profile
MinusZero
Level 4

05-11-2018

Hi martynd4832568​,

You may need to copy each row with it's specific instance reference.

The first repeating row in the table with be specified with [0], second row [1], third row [2] and so on.

Assuming which is the repeating row. Copying the first row actionItem rawvalue would be something like this.

this.resolveNode("Archive_Page.Table1.Row1.SubForm2.Table2.Row1[0].actionItem").rawValue = this.resolveNode("Main.Table1.Row1.SubForm2.Table2.Row1[0].actionItem").rawValue;

For the second physical row instance you would use [1], third row [2] and so on.

I hope this gives you the start you needed. They can be a bit tricky.