Expand my Community achievements bar.

Don’t miss the AEM Skill Exchange in SF on Nov 14—hear from industry leaders, learn best practices, and enhance your AEM strategy with practical tips.
SOLVED

Button to delete all empty rows

Avatar

Level 2

I am in the process of creating an interactive form that has a button that add rows for the user to input issues and another button to add follow-ups to those instances. There are 3 different sets of these. However, we do not want to add a delete button to all rows, to allow for accidental deletion of already inputted data.  I would like to create a button that will delete all empty rows, including all subforms.  Either that, or upon saving the document, all empty rows would be deleted - whichever would be easier. Please help!  This seems like it will be a complicated task and I am not that well versed in LiveCycle to be able to figure this out on my own.

Thank you!

1 Accepted Solution

Avatar

Correct answer by
Level 10

In the Object > Binding palette. I have included a screenshot on the forum.

Niall

View solution in original post

30 Replies

Avatar

Level 2

I see it.  Thank you thank you thank you!  Would you mind taking down the last form posted?

You have been the MOST helpful... I appreciate your time!

Avatar

Level 2

Okay - this is genuinely the last time I will bother you because this is the last thing I need for this awful form to be finished haha.  How would I add into the delete button, that if any follow-up rows are blank they should be deleted? I tried myself, and obviously, since I am clearly in way over my head with this project, it does not work.  I know it' smuch more complicated because it has to count through the original statements and then again through the follow-ups... is this even possible?

Avatar

Level 2

I am still stuck on how to get this button to delete blank follow-up rows to each statement.  I've played with it for several hours and can't come up with the proper code.  Is this possible to do or am I trying to complete something that can't be done?

Avatar

Level 10

It can be done - see example. However it does require each of the repeating elements to be set to an initial count of 1 and NOT a minimum count at all.

Also have a look at the form I sent back. There were some Row1 that were incorrectly set to repeat. This wasn't needed as the row was in a repeating subform. I corrected these.

Good luck,

Niall

Avatar

Level 2

There was no link or example attached to this post!

Avatar

Level 10

Hi,

I am out of the office and cannot post your form for a while.

The point I was making is that it can be done and I was referring you to the example I posted on the 15 Nov. (post 18). That was a working example that deleted all empty rows in all of the tables. You just need to follow that.

If script is failing you should open the JavaScript Console (Control+J), which should show you were the problem is.

Niall

Avatar

Level 2

It's fine no rush - I actually got all the rows to work except for the

follow-up statements. They are add instances of add instances and I'm not

sure of the syntax of how to locate that exact item. I'm assuming you have

to count through the first add instances and then count through the sub-add

instances but I keep messing it up!

Avatar

Level 10

There is no doubt that looping through nested repeating objects is more complex:

Here is the script for the first table with follow-up rows:

// Technical


var nCount3 = VitalsSubform.Technical._Instance1.count;



for (var k=0; k<nCount3; k++)


{



     // this is script to remove the follow-up rows in the first table only


     var nCount6 = xfa.resolveNode("VitalsSubform.Technical.Instance1[" + k + "]").Table1._Row1.count;



     // loop through the rows in the follow-up table


     for (var i=0; i<nCount6; i++)


     {


          if (xfa.resolveNode("VitalsSubform.Technical.Instance1[" + k + "].Table1.Row1[" + i + "]").Cell4.rawValue == null)


          {     


               // remove null row


               xfa.resolveNode("VitalsSubform.Technical.Instance1[" + k + "]").Table1._Row1.removeInstance(i);


               // recount nCount in case a row has been deleted


               nCount6 =xfa.resolveNode("VitalsSubform.Technical.Instance1[" + k + "]").Table1._Row1.count;


               // account for the row that is now deleted


               i = i-1;


          }


     }



     // now remove null statements


     if (xfa.resolveNode("VitalsSubform.Technical.Instance1[" + k + "]").Table1.Statement.Statement.rawValue == null)


     {


          VitalsSubform.Technical._Instance1.removeInstance(k);


          var nCount3 = VitalsSubform.Technical._Instance1.count;


          k = k-1;


     }


}

It is by no means tested and could still be flaky.
Have you considered a manual 'x'/delete button for the follow-up rows?
Niall

Avatar

Level 2

Ah yeah its not working properly it only deletes the follow ups on the first

statement and then nothing after that. Oh well thank you for your time!