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
Bedrock Mission!

Learn more

View all

Sign in to view all badges

Dynamic Table - Add rows and columns in same table

Avatar

Level 2

Hi there,

I wonder if someone could help please? I'm trying to create and table where a user can add both rows and columns (preferably with separate buttons) but am having trouble trying to figure out how to do this. Is it possible? If so how? I'm not familar with script but have found examples of seprate tables where you can add a row and then another table where you can add columns and essentailly want to merge the two but cannot make it work.

Any help much appreciated!

Thanks,

Ken

4 Replies

Avatar

Level 6

Check for Instance Manager docuemntation for clues.....as per my knowledge we can only add rows but not columns dynamically. As say you have code examples for adding both rows and columns.....I can help you put them in context. Post here what you got then I will try my best to help you synk those.

Avatar

Level 2

Hi Varma,

Thanks for getting back to me so quickly. Please find a link below that contains two seprate tables - one where you can add rows and one where you can add columns. I've tried playing about with then but cannot seem to find a solution to have it combined so there is one table that you can add columns and rows to.

https://acrobat.com/#d=LM70D5rUcjgw*fv57USakA

Ken

Avatar

Level 6

It is great example....you can learn the concepts there and apply....however you may have to think twice before you implement column adding dynamically....because the technique here is make copy of what we already have and reproduce it as a new item and this technique works great for rows as they all have every thing in common. But when it comes to columns it may have unique visible identity as column head and displaying repeatedly the same column head may not look good. Of-Course you can do few extra lines of code and change the column appearance based on users input each time. Situations where users need to add additional column is very unlikely (sure your requirement might be an exception).

Key in allowing adding/removing instances is managing design mode settings under Object>>Binding>>....and select the checkbox "Repeat <subform/row/...> for Each Data Item" and then set Min, Max and Initial count values.

Also you need to club your effots by using simple scipt with button clicks....

for the example refered in URL you posted following is what I did to make the first table allow Adding/Removing Rows....

1. Opened the form in LC designer.

2. Add two buttons AddRow & RemoveRow right next to RemoveColumn

3. For AddRow I used following JS code....

      Table1._Row1.addInstance(1);//that means any time this button is clicked a new instance of Row1 is added use _Row2 or Row3 based on your needs


      var fVersion = new Number(xfa.host.version); // this will be a floating point number like "7.05"

      if (fVersion < 8.0) // do this for Acrobat versions earlier than 8.0
      {
       // make sure that the new instance is properly rendered
       xfa.layout.relayout();
      }

4.  For RemoveRow I used following JS code....

     Table1._Row1.removeInstance(1);//Syntax is...<objectReference>.removeInstance(<index of the repeating object that needs to be removed>); //in this case since we used 1 alwasys second object from top gets deleted.

      var fVersion = new Number(xfa.host.version); // this will be a floating point number like "7.05"

      if (fVersion < 8.0) // do this for Acrobat versions earlier than 8.0
      {
       // make sure that the new instance is properly rendered
       xfa.layout.relayout();
      }

5. Now time to update settings at Object>>Binding tab and set "Repeat......" and also set Min, Max and Initial count as explained above.

     Those settings needs to be updated for Row1 (or your choice of row) of the table

6. Set the Height to Expand of the Subform, where the table is housed....  this is done under Layout pallet

7. Save the PDF as dynamic template and verify the results...

If you still run into issues I can send you copy that works on my machine, but you need send me an email at n_varma(AT)lycos.com

Good luck,

Avatar

Level 2

Thanks Varma! I've managed to sort it following your advice. I didnt account for the 'binding' settings before, which is why I couldn't get it to work! Least I know now.

Thanks again,

Ken