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

SOLVED

ADD A ROW IN A SPECIFIC AREA OF THE TABLE

Avatar

Level 5

Good day,

 

I have a button at the end of each row which adds a row and keeps the information entered.  The problem is that the row is added under the last row.   I want to add the row under the row that is clicked.  Below is the script on each button.  Can someone help me with the script?

 

var nNewCardIndex = this.parent.parent.parent.instanceManager.count-1;
var sTargetNew = "headersubform.tablesubform.tablesubforms.Table1.Row1[" + nNewCardIndex + "]";
this.resolveNode(sTargetNew).ssfs.rawValue = this.parent.parent.ssfs.rawValue;
this.resolveNode(sTargetNew).dated.rawValue = this.parent.parent.dated.rawValue;

var cInput = xfa.host.response("Enter number of rows you want to add:", "Add rows", "1", false),
n = parseInt(cInput, 10) > 0 ? parseInt(cInput, 10) : 1,
i = 0;
for (i; i < n; i += 1) {
_Row1.addInstance(true);
}

if (!dated.isNull) {
var oRows = Table1.resolveNodes('Row1[*]'),
j = this.parent.index,
cDate = dated.rawValue;
for (j; j < oRows.length; j += 1) {
if (oRows.item(j).dated.isNull) {
oRows.item(j).dated.rawValue = cDate;
}
}
}

if (!ssfs.isNull) {
var oRows = Table1.resolveNodes('Row1[*]'),
j = this.parent.index,
cDate = ssfs.rawValue;
for (j; j < oRows.length; j += 1) {
if (oRows.item(j).ssfs.isNull) {
oRows.item(j).ssfs.rawValue = cDate;
}
}
}

1 Accepted Solution

Avatar

Correct answer by
Level 5

I am not clear on the complete requirement, but as far as adding a row under the row that is clicked, try this on button click

headersubform.tablesubform.tablesubforms.Table1.Row1.instanceManager.insertInstance(this.parent.index + 1, 0);

You may have to modify this.parent.index , seems you have more parents to your button.

View solution in original post

1 Reply

Avatar

Correct answer by
Level 5

I am not clear on the complete requirement, but as far as adding a row under the row that is clicked, try this on button click

headersubform.tablesubform.tablesubforms.Table1.Row1.instanceManager.insertInstance(this.parent.index + 1, 0);

You may have to modify this.parent.index , seems you have more parents to your button.