Expand my Community achievements bar.

Adding Rows and Columns to a table depending requirements

Avatar

Level 2

Hi all,

I have created a table with one row and 2 columns of a table. My client requested adding form one to 3 columns of the right table and rows as well, depending business requirements.

I can add coding add columns on the right, but I cannot add rows because the columns dynamic.

I tried to write the coding for adding rows but it is not successful.  Please help.

event : click - add colum button

for (var i = 0; i < form1.page1.Table1._Row1.count; i++){

var newrow = form1.page1.Table1.resolveNode("Row1[" + i + "]");

var newrow2 = form1.page1.Table1.resolveNode("HeaderRow[" + i + "]");

newrow._Col3D.addInstance(0);

newrow2._Col3D.addInstance(0);

}

i also published my file for your reviewing.

https://workspaces.acrobat.com/?d=xcgcfby89J-IHenn-8xeaQ

Thank you very much,

Cindy

3 Replies

Avatar

Level 10

addInstance receives a true or false value, 1 = true to add the instance and 0 = false do not add the instance.

should be written this way :

newrow.Col3D.addInstance(1);

newrow2.Col3D.addInstance(1);

Avatar

Level 2

Thanks for your helpful information.

The add column button is working. But I still have the problem the add rows button. I can add rows but I cannot the rows with dynamic columnsScriptingTableColumns4_test5_image.jpg

event : click - add colum button

 

form1.page1.Table1._Row1.addInstance(1)

Avatar

Level 10

When you are adding instances it uses the default properties of the object...

If its hidden as a default value in the form and you add an instance, the new instance will be hidden..

So if you have 3 columns in your default row and trying to add an instance withthe 5 columns it will only add a row with 3 columns..

If you want to add the columns to the table, you must add the column to each new row instance.

E.g.:

var intCount = xfa.resolveNode("page1.table1.Row1").instanceManager.count;

form1.page1.table1._Row1.addInstance(1);

xfa.resolveNode("page1.table1.Row1[" + intCount.toString() + "].Col3D").addInstance(1);