Skip to main content

Hi.

I am in need of pre-populating a dropdown list in a repeating section with different values according to the row number.

Let's say I set up a repeating section with 1 dropdown(Type) containing 9 values(Type1, Type2, ... Type9) with the option to allow the users to add a new type if need be and one field with a checkbox(Present).

I need the first 9 rows that are static containing the items in the list. 

Like this:

DropDown     Found

Type1              checkbox        row 1

Type2              checkbox        row 2

Type3              checkbox        row 3

...

Type9              checkbox        row 9

Add new type  checkbox        row 10+ 

I have been partially successful but all values are the same Type on every row.

Not like this:

DropDown     Found

Type1              checkbox        row 1

Type1              checkbox        row 2

Type1              checkbox        row 3

...

Type1              checkbox        row 9

Add new type  checkbox        row 10+ 

How do I setup a rule or use jQuery for this?

Thanks.

could you post code you use to populate dropdown with 'type1' value?

(it'll be faster to update your code then to start from scratch)


Hi Marian,

Type1 = "Ultram/Tramadol", Type2 = "Neurontin/Gabapentin", Type3 = "Paxil/Paroxetine"

We are in the process of purchasing Nintex at the moment.

It is expired but this is the rendition that only selected row 4.

This code only accounts for 3 set rows. I attempted a switch case. The if then statement had the same results.

I called this from a calculated field. It does get the row number properly but always defaults to last option.

//Show Current row number
function PopulateDDL(i){
//alert(i);
//var i = "";
//NWF$(".rsCONMEDNP").find("option:contains(Ultram/Tramadol)").attr('selected', 'selected');

if (isNaN(i)) {
console.log("That was not a number!");
} else if (i = 1) {
NWF$(".rsCONMEDNP").find("option:contains(Cymbalta/Duloxetine)").attr('selected', 'selected');
console.log("..1");
} else if (i = 2) {
NWF$(".rsCONMEDNP").find("option:contains(Neurontin/Gabapentin)").attr('selected', 'selected');
console.log("..2");
} else if (i = 3) {
NWF$(".rsCONMEDNP").find("option:contains(Paxil/Paroxetine)").attr('selected', 'selected');
console.log("..3");
} else {
NWF$(".rsCONMEDNP").find("option:contains(Please select a value...)").attr('selected', 'selected');
console.log("...");
}


Case Switch did not work either
/*
switch {
case (i = 1):
//NWF$('.CONMEDNP).attr("value", "Cymbalta/Duloxetine");
alert("1");
//NWF$(".rsCONMEDNP").find("option:contains(Cymbalta/Duloxetine)").attr('selected', 'selected');

return delay(1000).then(function() {
NWF$(".rsCONMEDNP").find("option:contains(Cymbalta/Duloxetine)").attr('selected', 'selected');

});

break;
case (i = 2):
alert(2);
//NWF$('.CONMEDNP).attr("value", "Neurontin/Gabapentin");
//NWF$(".rsCONMEDNP").find("option:contains(Neurontin/Gabapentin)").attr('selected', 'selected');

return delay(1000).then(function() {
NWF$(".rsCONMEDNP").find("option:contains(Neurontin/Gabapentin)").attr('selected', 'selected');
});
break;
case (i = 3):
alert("3");
//NWF$('.CONMEDNP).attr("value", "Paxil/Paroxetine");
NWF$(".rsCONMEDNP").find("option:contains(Paxil/Paroxetine)").attr('selected', 'selected');
break;
default:
alert("4");
//NWF$('.rsCONMEDNP').attr("value", "");
NWF$(".rsCONMEDNP").find("option:contains(Please select a value...)").attr('selected', 'selected');
break;
}
*/
}
PopulateDDL(2);

Edit: Wow-did not know replying to email made things look so bad. Tried clean it up a little.


I figured it out and it works nicely.

I am using this How to set the default value of a single line textbox to a calculation to lookup() 

Just need to figure out how to hide/disable delete ability on just those rows. 

I tried this bit it does not work.

NWF$(this).find('.nf-repeater-deleterow-image').hide();

It just deletes the added rows one at a time.


have a look eg. on this  


I ended up using that. Thank you.

I am still wanting to figure out how to just disable the the pre-loaded rows and allow the users to only delete the add rows. 

I thought for sure the highlight would have worked.

CRFs 

 
function setControl(rowNum, value) {
 
    repeatingSection = NWF$('.rsLineItems');
//alert(repeatingSection);
    if (value != "") {
        //This line filters any HTML placed by Nintex.  Leave out if using a numerical column return
        //var regex = /( |<(^>]+)>)/ig,
          var regex = /(|<(^>]+)>)/ig,
            result = value.replace(regex, "");
        //This grabs EVERY textbox with the CSS class of txtControl
        var Textboxes = NWF$(repeatingSection).find('.txtControl');
        //And this loops through those textboxes until the index matches the passed row number
        NWF$.each(Textboxes, function(index) {
            if (index == rowNum) {
                //NWF$(this).val(result);
NWF$(this).val(result).find('.nf-repeater-deleterow-image');
                //NWF$(this).find('.nf-repeater-deleterow-image').css("visibility", "hidden");
if (rowNum <= 18) {
//alert(rowNum <= 18);
                      NWF$(this).find('.nf-repeater-deleterow-image').css("visibility", "hidden");
                      }
            }
        });
    }
}

have a look on this  


Thanks. I will look into the link thoroughly. 

Using a rule would be ideal. 

Essentially I just need to remove the "X" delete link from specific rows. I was hoping simple jquery would do it. I have done it in the past but that method did not seem to work here. 

I have had some cases where I had to remove the delete if the values were a certain type. So in a list I might only be able to delete rows 1,2,6, and 9 and the other rows were only able to be deleted by someone else. 

It will take a minute but I think I will get it.


it's quite easy if you base condition on a value that you have on a form.

but there is not apparent flag/value that would distinguish rows that were already existing at form opening to ones added during session. therefore that complexity.

but if you have simpler solution, I would be glad to see it.


True. I was hoping I could based on the rownumber and add a field to the lookup that would distinguish if delete is possible. Changing the values is a needed thing.

Ideally this is exactly what we need. As you can see the items with out an "X" are pregenerated and are not permitted for deletion. And the user can delete any the need to that they added. 

It really seemed like this would have worked. This is as simple as I needed but I just need to get the call right. 

NWF$.each(Textboxes, function(index) {
            if (index == rowNum) {
                NWF$(this).val(result);

if (rowNum <= 8) {
//alert(rowNum <= 8);
                      NWF$(this).find('.nf-repeater-deleterow-image').css("visibility", "hidden");
                      }
            }
        });


try this

NWF.FormFiller.Events.RegisterAfterReady(function () {
   if ( Is Edit Mode){
         NWF$('.rsLineItems .nf-repeater-row:not(.nf-repeater-row-hidden) .nf-repeater-deleterow-image').css("visibility", "hidden");
   }  
}) ‍‍‍‍‍‍‍‍‍‍

‌ delete row‌


Thank you.

The page never seems to load. I will experiment some and see what I come up with.

One thing I also tried but it does not work is to .removeclass() when the the initial items populate the list. That does not work either.


forgot to point out that "Is Edit Mode" text has to be replaced with IsEditMode reference.

did you do it or simply copy&pasted the script?


Yes. then changed to IsEditMode.

I also comment that out and tried just 

NWF$('.rsLineItems .nf-repeater-row:not(.nf-repeater-row-hidden) .nf-repeater-deleterow-image').css("visibility", "hidden");

I also tried it with rest of my code that preloads the entries. Same thing.

Please wait... comes up and it will eventually time out.


try to run the form with developer console open to see what errors are reported


It works. I re copied the code in there. Removed the reference to the edit only since it will be used in new and edit.

I am not sure what happened before. Cached maybe. Not sure. It works and moving forward will be easier.

Even the indexes appear right. No more deleting the first delete-able row and the last row gets deleted.

Thank you for all your help on this. 

This will make it easier for the users to update the lookup list contents and not need to bother me as much. 


Reply