Expand my Community achievements bar.

SOLVED

Repeating row data export moves to the far right in spreadsheet

Avatar

Level 9

My form has one dynamically repeating row by the user clicking a button. I have it set to a maximum of 8 rows. Some form users only need one row while others need more than one. When I export the forms using Arcobat X, any form with more than one row exports the other row data to the very far right column in Excel. This makes reviewing the data difficult with one row in a column in the middle of the spreadsheet and the rest a full page width to the right. Is there anyway I can keep these together regardless of how many rows are dynamically created (up to the max number allowed)?

Should I hide the table rows instead of creatin them dynamically? If yes, how do I make one at a time visible with a button?

Thanks

1 Accepted Solution

Avatar

Correct answer by
Level 2

The "rowObj[*]" field was just an example. You needed to replace it with the name of your rows. So based on your example form, the code would be:


rowNodes = xfa.resolveNodes("form1.#subform[0].Action.Table1.MoreActions[*]");

for (var rowCount = 0; rowCount < rowNodes.length; rowCount++) {

  // if this row is hidden, then show it and exit the loop

  if (rowNodes.item(rowCount).presence === "hidden") {

   rowNodes.item(rowCount).presence = "visible";

   break;

  }
}

Make sure you get that last closing bracket too, I missed it in the first chunk of code I posted.

Another problem in the form is that you have "Repeat Row for Each Data Item" checked in the binding tab. Remove this for all rows. The rows are there all the time (although they may be hidden), their presence is not driven by the data so this is not needed.

Also, your remove row buttons script will need a change from:

_MoreActions.removeInstance(this.parent.index);

to:

this.parent.presence = "hidden";

View solution in original post

5 Replies

Avatar

Level 2

Since you know that you never want more than 8 rows, you could show/hide the rows rather than create them to ensure consistent data.

To show a row, you will need to check each row to find the first hidden row and make it visible. Code might be something like this:

 

rowNodes = xfa.resolveNodes("rowObj[*]");

for (var rowCount = 0; rowCount < rowNodes.length; rowCount++) {

  // if this row is hidden, then show it and exit the loop

  if (rowNodes.item(rowCount).presence === "hidden") {

   rowNodes.item(rowCount).presence = "visible";

   break;

  }

To remove a row, you will do a similar thing in reverse, i.e. loop through from the end until you find a visible row. Before hiding it though, you will need to clear any data that was entered.

Avatar

Level 9

I can't get the script above to work.

I created 9 identical rows and set them to hidden (exclude from layout). The subform is set to flowed and I copied the script and added it to the click event of the button. What am I doing wrong?

Avatar

Correct answer by
Level 2

The "rowObj[*]" field was just an example. You needed to replace it with the name of your rows. So based on your example form, the code would be:


rowNodes = xfa.resolveNodes("form1.#subform[0].Action.Table1.MoreActions[*]");

for (var rowCount = 0; rowCount < rowNodes.length; rowCount++) {

  // if this row is hidden, then show it and exit the loop

  if (rowNodes.item(rowCount).presence === "hidden") {

   rowNodes.item(rowCount).presence = "visible";

   break;

  }
}

Make sure you get that last closing bracket too, I missed it in the first chunk of code I posted.

Another problem in the form is that you have "Repeat Row for Each Data Item" checked in the binding tab. Remove this for all rows. The rows are there all the time (although they may be hidden), their presence is not driven by the data so this is not needed.

Also, your remove row buttons script will need a change from:

_MoreActions.removeInstance(this.parent.index);

to:

this.parent.presence = "hidden";

Avatar

Level 9

Now I understand - works great!

Thank you so much!

~Don