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

Row Index Problem in Table

Avatar

Level 4

I am having a problem assigning data to fields in a table.

I have a table with three columns, one row, and I have a button to delete a row and a button to add a new row.  My problem is that when I add information to three other fields on my form and click the add button it won't assign that data to the fields in the table.  Here is a one of the lines of code that I am having a problem with.

--------- Begin Code -----------

var rowIndex = subGroupData.tblComments.rowGroupData.instanceManager.count - 1;

subGroupData.tblComments.rowGroupData[rowIndex].rowEmplName.rawValue = $.strFullName.rawValue;

--------- End Code -----------

The problem lies in the brackets.  When I put a 0 in the brackets it copies the data fine into the table.  When I use a variable that is assigned a number it doesn't work at all.  I have verified using a message box that I am getting the correct index number using my rowIndex variable.

Any thoughts?  I have tried even using parseInt() but that doesn't work either.

Thanks,

John

4 Replies

Avatar

Level 10

Change your code like this..

     subGroupData.tblComments.resolveNode("rowGroupData[" + rowIndex + "]").rowEmplName.rawValue = $.strFullName.rawValue;

Thanks

Srini

Avatar

Level 4

Srini,

I had to modify what you sent me and it worked perfect! Thank you! Where did you find out this? I have looked through all sorts of documentation on XFA and Javascript and haven't seen this.

Here is what I ended up with:

subGroupData.tblComments.resolveNode("rowGroupData[" + rowIndex + "]").rowEmplName.rawValue = $.strFullName.rawValue;

I just needed to remove the asterisks.

Thanks!

John

Avatar

Level 4

John,

To answer your question, resolveNode is expecting a String representation of a somExpression.  So you needed to build the string in order to actually reference the node.  So:

resolveNode("MyNode[" + counter + "]")

is the same as:

var myPath = "MyNode[" + counter + "]";

resolveNode(myPath);

However, without the string concatenation for the variable rowIndex, you'd be trying to do something like:

resolveNode("rowGroupData[rowIndex]").  and since rowIndex is being treated as part of the string instead of getting it's value, the index cannot be found.  Appending it to the string by " + rowIndex + "  actually puts the rowIndex value in.  (Everything in ""s are literal values...outside of ""s, everything is considered a reference to something else.

Hope that helps, I know that may seem mildly confusing,

Alex

Avatar

Level 1

I have a similar problem and was hoping you could help me..

I have an expandable table with DropDown as one of the cells in every row. I have the value I am trying to add to the each of the dropdown in every row as it expands.My code looks like this. Being new at this, I am really struggling and any help would be greatly appreciated.... thanks Fay

FORM.MAIN.TblOrderForm.resolvenode("Row1["+i+"]").DataDropList.additem("CurrentVal");