cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Workflow Hero

Insert a row in a repeating section?

Jump to solution

I have a form with a repeating section on it, and would like to set up the ability to insert rows in that section, rather than add them on the bottom of the section like the default behavior for the "Add new row" link. 

I have the repeating section configured to include an "insert row" link for each one, but can't find a function that will insert a row above (or below, doesn't really matter) the row where the "insert row" link is clicked.  I am guessing there is some sort of JavaScript function built in that looks for the last child in the repeating section, and appends the new row.  I can get the index number of the "Insert Row" link that is clicked with .index() to figure out after/before which row the new one should be added, but just need the function that creates the row to pass that parameter to.

sample repeating section wiht insert row link

Thanks for any help/guidance anyone can provide!

Labels: (2)
Reply
13 Replies
Workflow Hero

Re: Insert a row in a repeating section?

Jump to solution

‌ I like what you are trying to achieve here - did you manage to get it working?

0 Kudos
Reply
Workflow Hero

Re: Insert a row in a repeating section?

Jump to solution

‌ I have not been able to get it working so far   We are using a work-around of having some hidden rows that people can "insert", but the solution is not optimal since the number of rows that one can insert is limited with this approach.

Reply
Workflow Hero

Re: Insert a row in a repeating section?

Jump to solution

‌ any of your magic javascript that can achieve this?

0 Kudos
Reply
Workflow Hero

Re: Insert a row in a repeating section?

Jump to solution

Hi Yana,

See Marian Hatala‌'s answer in this post: ‌.

Reply
Workflow Hero

Re: Insert a row in a repeating section?

Jump to solution

I was able to figure out a solution to this using JavaScript.  Instead of focusing on inserting a row, what I did was use the Nintex Forms action to add a new row on the bottom, and then shift the existing data down a row (depending on which row was clicked).

// add-repeat is the class for my "Insert Row" rich text

NWF$(".add-repeat").on("click", function() { // When the "Insert Row" element is clicked...
    NWF$(".ms-addnew").click();    // Activate the "add new row" that comes with the form
    var numRows = NWF$(".add-repeat").length - 1;
    var index = NWF$(".add-repeat").index(this); // Get number of row where "Insert Row" is clicked
    if (numRows >= 3) { // I only want this to run under this condition, but you can remove it
     for (var i=numRows; i>=index; i--) {
      var valueStore = NWF$(".nf-repeater-row").eq(i).find('input').val();
      NWF$(".nf-repeater-row").eq(i+1).find('input').val(valueStore);
     }
}
    NWF$(".nf-repeater-row").eq(index+1).find('input').val('');
})‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍
0 Kudos
Reply
Workflow Hero

Re: Insert a row in a repeating section?

Jump to solution

What event did you add behind the Insert row, was it something linke this??

<a id="myLink" href="#" onclick="MyFunction();">link text</a>
0 Kudos
Reply
Workflow Hero

Re: Insert a row in a repeating section?

Jump to solution

The Insert row is just a Rich Text control, it's not an actual link (I didn't want to mess with the 'edit source' in the rich text control).  The control has the CSS class add-repeat, and the event listener in my code waits for a click on an item with that class name, but it doesn't need to actually be a link.

Reply
Workflow Hero

Re: Insert a row in a repeating section?

Jump to solution

Link to form

Please see above the link to form, i am trying to do exact same thing, it seems I maybe missing an event.

0 Kudos
Reply
Workflow Hero

Re: Insert a row in a repeating section?

Jump to solution

I was also hoping if you could share your form, so i could figure it out what I am doing wrong...

0 Kudos
Reply