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

Deleting the current row in a table

cl5792
Registered: Jul 17 2008
Posts: 53
Answered

I have a table in a Livecycle form where new rows can be added and I need to add the functionality to delete a specific row from the table.

I have a button to add rows that works.

----- Root.Page3.EnterNewRows.HeaderRow[0]..Subform1.Button1[0]::click: - (JavaScript, client) ---------------

EnterNewRows._Detail.addInstance();

I have been able to add a button to delete a row but it only deletes the last row added.

----- Root.Page3.EnterNewRows.HeaderRow[0].Subform1.Button1[1]::click: - (JavaScript, client) --

EnterNewRows.Detail.instanceManager.removeInstance(1);

How do you remove a row (say the 3rd of 10)? Also how do you determine the index or row number of a row within the table? instanceManager.count does not seem to be available.

My Product Information:
LiveCycle Designer, Windows
thomp
Expert
Registered: Feb 15 2006
Posts: 4411
Each instance of a subform has an "index" property. So the code for a delet button that is inside the repeatable subform would be.

this.parent.instanceManager.removeInstance(this.parent.index);

You can find video tutorials that explain the LiveCycle scripting environment at www.pdfscripting.com

Thom Parker
The source for PDF Scripting Info
[url=http://www.pdfScripting.com]pdfscripting.com[/url]

The Acrobat JavaScript Reference, Use it Early and Often
[url=http://www.adobe.com/devnet/acrobat/javascript.php]http://www.adobe.com/devnet/acrobat/javascript.php[/url]

Thom Parker
The source for PDF Scripting Info
www.pdfscripting.com
Very Important - How to Debug Your Script

cl5792
Registered: Jul 17 2008
Posts: 53
How would you reference the row in the subform if the delete button is outside of the table? How do you get the index of a row?

thank you
thomp
Expert
Registered: Feb 15 2006
Posts: 4411
How do you want to get the index of a row? If the delete button is in the row, then it's pretty obvious which row will be deleted. But if it's outside, then how do you decide? A check box in the row? There has to be something. What do you want?

Thom Parker
The source for PDF Scripting Info
[url=http://www.pdfScripting.com]pdfscripting.com[/url]

The Acrobat JavaScript Reference, Use it Early and Often
[url=http://www.adobe.com/devnet/acrobat/javascript.php]http://www.adobe.com/devnet/acrobat/javascript.php[/url]

Thom Parker
The source for PDF Scripting Info
www.pdfscripting.com
Very Important - How to Debug Your Script

cl5792
Registered: Jul 17 2008
Posts: 53
I'm sorry I was not more specific. I was wondering if there was a way to capture the index of last row entered. But if there is not then I can add a check box to the row. If I do this and multiple rows can be checked to delete, how do I get the index for the rows to remove from outside of the table? The delete rows button is not in the table.
thomp
Expert
Registered: Feb 15 2006
Posts: 4411
You know that the "addInstance" fucntion returns the subform it creates, so you can get the index at that time. If you mean the last row where the user entered data, then you need code that detects that.

To the get the indexes of the rows that are checked, the code needs to loop through the subform instances and test the value of the check box in each row.

Do you have the "XML Forms Object Reference"? A lot of this information is in it. You'll find it and seveal other useful documents here:

http://partners.adobe.com/public/developer/xml/topic.php

You should also watch Extending LiveCycle with JavaScript eseminar on this site.
http://www.acrobatusers.com/learning_center/eseminars_on_demand

And you'll find much more detailed scrpting specific info and samples at www.pdfscripting.com

Thom Parker
The source for PDF Scripting Info
[url=http://www.pdfScripting.com]pdfscripting.com[/url]

The Acrobat JavaScript Reference, Use it Early and Often
[url=http://www.adobe.com/devnet/acrobat/javascript.php]http://www.adobe.com/devnet/acrobat/javascript.php[/url]

Thom Parker
The source for PDF Scripting Info
www.pdfscripting.com
Very Important - How to Debug Your Script