These forums are now Read Only. If you have an Acrobat question, ask questions and get help from one of our experts.

dynamic table - insert a row in the middle of the table

smalbany
Registered: Jun 8 2010
Posts: 6

Is it possible to set up a table so that a user can insert a row in the middle of an already existing table with multiple rows.
 
let's say I've got a dynamic table and the user has created 10 rows. I'd like the user to be able to click on row five and be able to click a button allowing the user to create a blank row above (or below) row five.

My Product Information:
LiveCycle Designer, Windows
Masi
Registered: Sep 18 2008
Posts: 22
Use moveInstance function after addInstance a bit like this:

Table1._Row1.addInstance(1);
//use 'this.parent.index-1' if you want new row to be
//before the "current row" but check that it doesn't become -1.
Table1._Row1.moveInstance(Table1._Row1.count-1, this.parent.index+1);
smalbany
Registered: Jun 8 2010
Posts: 6
Sorry Masi, you are talking way over my head. I appreciate your help but I'm not a JavaScript programmer, could you please elaborate? For example, which object and which event gets the code? Talk down to me, I don't mind.
:-)
smalbany
Registered: Jun 8 2010
Posts: 6
I found the "Table1._Row1.addInstance(1);" and the "_Row1.removeInstance(this.parent.index);." but I'll need more detailed help to understand what I need to do.

thanks
Masi
Registered: Sep 18 2008
Posts: 22
Ok, lets say you have a table row with a button on one column. Then you should set the script I provided to you in the click event of that button. Table1 references the table name and should be fixed for your as you named your table. Row1 is the table row and should also named the way you did, if you named it TableRow and the table is named AwesomeTable, then the script would be:
AwesomeTable._TableRow.addInstance(1);
AwesomeTable_TableRow.moveInstance(AwesomeTable._TableRow.count-1, this.parent.index);

One thing you should understand is that if the button is located somewhere else, for example in a subform in a column, then the "this.parent.index" part should be fixed to match the hierarchy of the column structure. Lets say your field hierarchy is now something like this:
AwesomeTable
|-TableRow
| |-Column1TextField1
| |-ControlRowsSubform
| | |-AddRowAfterButton

then the script would be like this:
AwesomeTable._TableRow.addInstance(1);
AwesomeTable_TableRow.moveInstance(AwesomeTable._TableRow.count-1, this.parent.parent.index);

As you can see, this.parent.parent must reference the TableRow in hierarchy and the logic is that 'this' is the button (in hierarchy) and the first 'parent' is ControlRowsSubform (in hierarchy) and the second 'parent' is TableRow, which index is given to the function moveInstance.

Say which things you understand and which don't so I can explain the right things..
smalbany
Registered: Jun 8 2010
Posts: 6
Hi, remember me? Finally got a chance to work on this. I understand your code. You explained it beautifully. Only problem? It didn't work. It added a row at the bottom of the table. not inserted a row. So, I got curious and tried: "_Row1.insertInstance(this.parent.index);" and it worked!!! Sometimes the Gods smile down on you.
:-)

Really, thanks for your help. Had you not provided me your code I'd have never stumbled onto what I found.

Jeff