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

How disable a lookup list item displayed as option button

Hi All,

How to disable a lookup list item displayed as option button?

I need to disable list item 3.

I have tried

var catCtl = NWF$("#"+ jsvProcCat);

catCtl.find("option[title='List item 3']").attr('disabled', true);

AND

NWF$('#'+ jsvProcCat).find('input[value=\'List item 3\']').attr('disabled', true);

Thanks

0 Kudos
Reply
10 Replies
Not applicable

Re: How disable a lookup list item displayed as option button

Try something like this in your document.ready function-

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

  $("#"+ jsvProcCat + " input[value='List item 3']").attr('disabled', true);

}

Reply
Not applicable

Re: How disable a lookup list item displayed as option button

BTW I should probably have used prop() here rather than attr().

Although the attr() call works, at least in Firefox 38, in principle it's the property that is writeable on the element. The attribute "checked" is set in the HTML and shouldn't be editable.

See the JQuery docs for details.

Reply
sojanm
Nintex Newbie

Re: How disable a lookup list item displayed as option button

Thanks Colin,

Unfortunately both didn't work.

NWF$("#"+ jsvProcCat + " input[value='Goods']").prop('disabled', true);

and

NWF$("#"+ jsvProcCat + " input[value='Goods']").attr('disabled', true);

Reply
Not applicable

Re: How disable a lookup list item displayed as option button

Well that's odd, as I tried this in Firefox/Firebug before I posted my reply.

Have you checked that the variable "jsvProcCat" is present in the HTML being emitted by the form, and is set to the correct ID?  This is a feature in Nintex Forms that's annoyingly buggy. I know it doesn't work in several column types, but I personally haven't tried a choice column displayed in radio buttons.

Reply
Not applicable

Re: How disable a lookup list item displayed as option button

Ok. I just set up a minimal list with 2 columns-

Title (default)

Choice (choice with options: "Yes", "No", and "Maybe")

It turns out that choice fields (at least ones displayed as checkboxes) are one of several field types where the Nintex option to put the field ID in a Javascript variable just doesn't work. I assigned the ID to a variable named "ChoiceID", but this string does not appear in the HTML of the form.

(Note: please lets all log bugs on this until Nintex finally get around to fixing it)

So instead I used the workaround of putting a custom CSS class on the item. In fact tried 2-

Control CSS class: MyChoiceControl

CSS class: nf-form-input nf-section MyChoiceClass

With the code:

NWF$( function ($) {

  $("#"+ ChoiceID + " input[value='Maybe']").prop('disabled', true);         // doesn't work

  $(".MyChoiceControl" + " input[value='Maybe']").prop('disabled', true);    // works

  $(".MyChoiceClass" + " input[value='Maybe']").css('margin-left', '10em');  //works

});

Using the Control CSS class gets you closer to the actual input element, so is probably preferable. I'll try to upload a copy of the form XML but i'm not sure if these forums let us do that.

Reply
sojanm
Nintex Newbie

Re: How disable a lookup list item displayed as option button

Thanks Colin, really appreciate your effort.

I tried using css class and sadly it didn't work. What I am trying is in the main form just display the items in a list (Category) with one field called Title. I am using a list lookup control to display as option button, below is the setting for lookup list control

both cssProcCat and jsvProcCat exists in html of the form.

Reply
Automation Master
Automation Master

Re: How disable a lookup list item displayed as option button

do not set the same CSS class to both 'control CSS class' and 'CSS clas'!

you in fact assign the same class to two different HTML elements of different types. if you will then query some property, one of the controls need not support it and your script will error out, which in turn my cause rest of your javascript need not work properly.

to access control from javascript, custom class is typically set in just in 'control css class'

Reply
sojanm
Nintex Newbie

Re: How disable a lookup list item displayed as option button

Thanks Marian for suggestion, but it did not work also.

Reply
Automation Master
Automation Master

Re: How disable a lookup list item displayed as option button

I just commented on your recent picture, and it was meant as a general hint.

I haven't followed the whole thread so I do not say this is exactly your problem.

but going briefly through the discussion, you mentioned originally you want to customize lookup control, right?

Colin's test case is with choice column/control, so that definitely can not work.

as per your need to customize lookup control, that might be really tricky and challenging since lookup control values (options in your setup) are populated asynchronously after the form is loaded. meaning that in ready() or RegisterAfterReady() events, the control values are not populated yet! and there is no apparent event/trigger that might be caught when it's populated.

furthermore, with recent form releases there were significant changes introduced in lookup control functionality, that soon or later might break that customized functionality altogether.

so, consider whether it makes sense to spent time and effort with such a customizing.

Reply