cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
themos
Nintex Newbie

RepeaterRowDeleting event not triggered if last row

Jump to solution

Hey guys,

I'm trying to clear individual rows in a Repeating section, but the event doesn't seem to trigger if there is only one row...

E.g.

1) first row            X

2) second row      X

It works OK if I try to delete either of these two rows.

But then if I try it again on this:

1) first and only row      X

the event is NOT triggered!

Any idea why? is it a bug or a feature??

Here's the function I'm using to test this hypothesis:

NWF.FormFiller.Events.RegisterRepeaterRowDeleting(function() {
      console.log('here');
})

0 Kudos
Reply
7 Replies
Automation Master
Automation Master

Re: RepeaterRowDeleting event not triggered if last row

Jump to solution

it's by design. there has to be at least one row in RS

0 Kudos
Reply
themos
Nintex Newbie

Re: RepeaterRowDeleting event not triggered if last row

Jump to solution

I understand that, but why couldn't they delete the last row and programmatically add a new (empty) row in a single atomic action?

Could we do that ourselves programmatically?

0 Kudos
Reply
Automation Master
Automation Master

Re: RepeaterRowDeleting event not triggered if last row

Jump to solution

good question, but I do not know the answer either

to do it on your own, you can simulate click on 'Add new row' to add new empty row and then simulate click on 'Delete row' for first row to remove populated row.

0 Kudos
Reply
themos
Nintex Newbie

Re: RepeaterRowDeleting event not triggered if last row

Jump to solution

But if you want to keep the same User Experience, you would have to programmatically detect that there is only 1 row left in the Repeating section (doable but costly, you would have to loop through the rows manually using

.find(".nf-repeater-row:not('.nf-repeater-row-hidden')").each(function () { ... }

), then catch the deletion event (keep in mind that only the Deleted event is fired and NOT the Deleting one), then programmatically add an empty row using

.find('.ms-addnew').click();

, AND THEN FINALLY force delete the original row that actually has data! Kinda overkill, IMHO...

The key is, how do they know when NOT to fire the Deleting event if a single row is left?? If they have that part down, then it would be easy to first trigger a new (blank) row insertion, and then let the Deleting event proceed as normal!

I really don't believe we need to open a Bug Report for this!

0 Kudos
Reply
Automation Master
Automation Master

Re: RepeaterRowDeleting event not triggered if last row

Jump to solution

you're very right, but that should be addressed to nintex

if you feel it's not correct functionality you can open a ticket with them.

this is how do they prevent to delete last row

var repeaterRows = NWF$(thisRepeaterControl.children('.nf-repeater-row'));
if (repeaterRows.length - 1 > parseInt(thisRepeaterControl.data('MinRows'))) {

so, two learnings out of that

- you need not to iterate through all the repeater rows to determine how many rows is actually there

- despite designer do not allow you to set MinRows to a value lower then 1, you should be able to force it to 0 in your code. however, I've never tried it and I do not know what might be side effects, once nintex wants to have at least 1.

Reply
themos
Nintex Newbie

Re: RepeaterRowDeleting event not triggered if last row

Jump to solution

Thanks for that code snippet, I'm sure it will come in handy in several occasions!

I'll do some more tests and post back the results!

Reply
Not applicable

Re: RepeaterRowDeleting event not triggered if last row

Jump to solution

May I mark this "assumed answered?" or mark one of Marian's replies (even though the answer isn't exactly what you wanted to hear)?  :-)

Reply