Expand my Community achievements bar.

Add a column with a button?

Avatar

Level 2

Hello again!

I am currently working on creating a form and my employeer requested an added functionality that I am not sure is possible in LiveCycle.

We currently have a 2 column layout, but he wants to include the ability for the user to click on a button and add an additional column for comments.

I have seen video tutorials and threads about the ability to add rows with a button, so I know that much is possible - but can you do this with columns as well?

Thanks so much in advance!

Best Regards,

Ashley

1 Reply

Avatar

Level 7

I've seen it done with imported data when the table is initialized. If you really need a clean table, you can try to modify this to suit your needs.

http://blogs.adobe.com/acdc/2009/02/dynamically_creating_a_table_w.html

Otherwise, if the table isn't too large, you could simply hide a three-column table that overlaps the two-column table you started with. Then just add script to copy the information over. This script will count the number of rows in the in the original table and make the appropriate number of rows in the new table. While making rows, it copies in the data from the old table. For my test, I put it on the click event of an "add column" button, and there were only two columns before I made the new table--hence, j<3.

var rowCount = tNoComments.Row.instanceManager.count;

tWithComments.presence = "visible";

for (var i = 0; i < rowCount; i++){

     if (i != 0) tWithComments.Row.instanceManager.addInstance();

     for (var j = 1; j < 3; j++) {

          xfa.resolveNode("tWithComments.Row["+i+"].TextField"+j).rawValue =           xfa.resolveNode("tNoComments.Row["+i+"].TextField"+j).rawValue;

     }

}

tNoComments.presence = "invisible";

If the user is going to have like 10 rows before he realizes he needs a comment, then this will work. If you're going to get to 30 or so and make a comment, then it's going to be unwieldy and cause the form to lag (maybe).