cancel
Showing results for 
Search instead for 
Did you mean: 

Dynamic Table Index Number

john_lee7
Participant
0 Kudos

I am trying to add/delete row from Adobe form.

There is no direct way to add/delete row dynamically and communicate between adobe form and Web Dynpro, I am trying to figure out differnt way...

Does anyone know how I can figure out index number of current row user clicked add/delete button from adobe form.

I tried several different ways to get index value, but all of them return blank, -1, or 1.

Thanks for any help you can give.

John

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi John,

Create a table with the binding "Repeat Table for each data item" with min count as 1. similarly write this binding for the row with min count as 1. Also create only one row. And for header row make min count as 1 and max count as 1, in pagination make check the "Include header row in initial page" and also "include header row in subsequent pages".

Now include create one button in "Header Row" make this as "Add" and one button in "Row" make this as "delete".

Now in the JavaScript editor for

ADD Button: Click event

// nTableLength stores the number of XML elements contained in TableName.

var nTableLength = TableName.nodes.length;

// nNumRow is used to calculate the number of rows contained in TableName.

var nNumRow = 0;

// This script uses a For loop to cycle through all of the XML elements

// contained in TableName.

for (var nCount = 0; nCount < nTableLength; nCount ++) {

// If the current XML element in Table2 is of type subform and it

// is not a header row, then increment the variable nNumRow by one.

// If the table included a footer row, this script would have to

// account for it.

//

// Note: In the Adobe XML Form Object Model, all table rows are

// considered subform objects.

if ((TableName.nodes.item(nCount).className == "subform") & (TableName.nodes.item(nCount).name !== "HeaderRow")) {

nNumRow = nNumRow + 1;

}

}

// An if-else statement is used to prevent form fillers from adding

// more than the maximum number of seven rows to a table.

if (nNumRow == 7) {

xfa.host.messageBox("The maximum allowable number of rows is 7. You cannot add any more rows.", "Warning", 3);

}

else {

// This script uses the addInstance() method to add a new instance

// of the RowName object contained in TableName.

subformname.TableName.RowName.instanceManager.addInstance(1);

}

DELETE button: Click Event

// nNumRow is used to calculate the number of rows contained in TableName.

var nNumRow = 0;

// nTableLength stores the number of XML elements contained in TableName.

var nTableLength = TableName.nodes.length;

// This script uses a For loop to cycle through all of the XML elements

// contained in TableName.

for (var nCount = 0; nCount < nTableLength; nCount ++) {

// If the current XML element in TableName is of type subform, and it

// is not a header row, then increment the variable nNumRow by one.

// If the table included a footer row, this script would have to

// account for that.

//

// Note: In the Adobe XML Form Object Model, all table rows are

// considered subform objects.

if ((TableName.nodes.item(nCount).className == "subform") & (TableName.nodes.item(nCount).name !== "HeaderRow")) {

nNumRow = nNumRow + 1;

}

}

// The Adobe XML Form Object Model uses a zero-based indexing system

// for referencing objects. In this script, the variable nNumRow represents

// the exact number of rows contained in Table1. To convert this to a usable

// index value, the script subtracts one.

nNumRow = nNumRow - 1;

// An if-else statement is used to prevent form fillers from removing

// the single remaining row from a table.

if (nNumRow < 1) {

xfa.host.messageBox("The minimum allowable number of rows is 1. You cannot remove any more rows.", "Warning", 3);

}

else

{

// This script uses the removeInstance() method to remove the last

// instance of the Row1 object (represented by nNumRow) contained

// in TableName.

//subform.TableName.Row1.instanceManager.removeInstance(nNumRow);

_RowName.removeInstance(this.parent.index);

}

NOTE:

1. TableName is Name of your Table

2. RowName is the Name of Row in the Table it is like for eg. Row1

3. subformname is the subform name where the table is present

With the above code you can dynamically add or delete rows

Regards

Pradeep Goli

john_lee7
Participant
0 Kudos

Pradeep,

Awesome!!!

It works.

Thank you very much.

John

Edited by: John Lee on Nov 20, 2008 8:43 PM

Former Member
0 Kudos

Hi Pradeep Goli ,

Thanks for ur post.

I got it correct. no java script error.

But am not able to see the new row on PDF from when i click on ADD button.

Will / Can I have the same effect as when i click on add button in Web DynPro application and can see the new row.

if yes than how Plz help.

Thanks & Regards

Arvind

Former Member
0 Kudos

Have u got any other solution

for Dynamocally adding rows to a table

in Adobe Interactive Form in web Dynpro Java

also

My Submit button is not working

Do you have any idea what might have went wrong

p[lease reply as soon as possible

Answers (0)