cancel
Showing results for 
Search instead for 
Did you mean: 
Automation Master
Automation Master

Re: Dynamically add a new row to a repeating section

Jump to solution

Maybe when one row is deleted, it removes the custom CSS class at row level (the div with the nf-repeater-row class).

If it is the case, you can try to add an attribute instead of a CSS class :

function AddRow(control,controlname) {

     if(NWF$("#"+control).find("input:checked").val()=="No" ) {

          NWF$(".myrepclasss").find('a').click();

          setTimeout(function() {

               NWF$(".myrepclasss .nf-repeater-row:last").attr("myattribute",controlname);

          }, 300);

     }

}

function RemoveRow(control,controlname) {

     if(NWF$("#"+control).find("input:checked").val()=="Yes" ) {

          alert(NWF$(".myrepclasss [myattribute="+controlname+"]").find('.nf-repeater-deleterow-image').html());

          if(NWF$(".myrepclasss [myattribute="+controlname+"]").find('.nf-repeater-deleterow-image').html()=="") {

               NWF$(".myrepclasss [myattribute="+controlname+"]").find('.nf-repeater-deleterow-image').click();

          }

     }

}

Reply
Not applicable

Re: Dynamically add a new row to a repeating section

Jump to solution

Hi Caroline,

Thanks for sharing.This approach seems to work and the correct rows , do get deleted.

Is there anyway to not show the default row of the repeating section ? I mean to be able to just show "Add new Row" on the repeating section initially . When the user clicks on 'Add New Row' , only then should the first row with some attribute

Thanks again for the awesome support you have provided .

0 Kudos
Reply
Automation Master
Automation Master

Re: Dynamically add a new row to a repeating section

Jump to solution

You're welcome

You can maybe hide it with JavaScript but I don't know if it is good idea : there could be side effects. You have to well test it.

Are you sure that using repeating section is useful in your case ?

Isn't it better to just show/hide several controls placed in a panel (one panel for each yes/no button) and add a rule to show or hide the panel depending on the value of the corresponding yes/no button ?

0 Kudos
Reply
Not applicable

Re: Dynamically add a new row to a repeating section

Jump to solution

Caroline,

i think rep​eating section control is a close match to the business req that we have .

1. We have several yes/no radio buttons.

2. We have a repeating section with several text boxes in it. Some of the text boxEs will be populated based on the radio button changed.

3.on selection of each no , a correspondinv row should be added to the rep section.

4.On selection of no from first radio button , first row should be created on the rep section. But by default the first row is already present in the rep section.

5. The users should be able to add more rows of required .

0 Kudos
Reply
omourad
Nintex Newbie

Re: Dynamically add a new row to a repeating section

Jump to solution

This is my preferred way using Nintex Forms APIs:

// get filler and repeater DIVs

var thisRepeaterControl = NWF$('.nf-repeater.' + formRepeatingClassName);

var formFillerDivCurrent = NWF.FormFiller.Functions.GetFillerDivObjectForControl(thisRepeaterControl);

//Add a row to your repeater using this line:

NWF.FormFiller.Functions.AddNewRepeaterRow(thisRepeaterControl, formFillerDivCurrent);

Reply
Automation Master
Automation Master

Re: Dynamically add a new row to a repeating section

Jump to solution

OK, well you can try to always hide the first row at the page loading (but the row will always be present in the XML where the repeating section data are stored) :

NWF$(document).ready(function() {

     NWF.FormFiller.Events.RegisterAfterReady(function() {

          NWF$(".myrepclasss .nf-repeater-row:first").hide();

     });

});

I haven't done it, so test a lot

Hope this helps

0 Kudos
Reply
Not applicable

Re: Dynamically add a new row to a repeating section

Jump to solution

Hi Caroline,

Thanks for the tip. I'm able to hide the repeating section first row but there are few controls that are * mandatory inside the repeating section and these controls cause validation when the form is saved .

Since these controls are within the repeating section row and the row is hidden, when the form is saved , the required controls validations gets fired .

Thanks,

0 Kudos
Reply
Automation Master
Automation Master

Re: Dynamically add a new row to a repeating section

Jump to solution

You can populate test values in those controls using JavaScript just after hiding the row

Reply
Not applicable

Re: Dynamically add a new row to a repeating section

Jump to solution

Exactly , That's what  I was on atm.

Thanks

0 Kudos
Reply
Not applicable

Re: Dynamically add a new row to a repeating section

Jump to solution

Hi Caroline,

I have about 6-7 text boxes within my repeating section. When I hide the repeating section first row , it leaves a big blank space in its place. Is there anyway to get rid of that ?

Thanks,

0 Kudos
Reply