locked
LS HTML Client disable specific item in a list RRS feed

  • Question

  • I am trying to disable specific items on a list depending of a simple condition.

    I added the code in the

    myapp.DataElement.RowTemplate_postRender
    event.

    I tried the 2 options below... did not work:

                itemRowParent.attr('disabled', true);
                contentItem.isEnabled = false;
    Any ideas on how to do this. Thanks.


    • Edited by JCMonto Thursday, June 6, 2013 11:31 PM
    Thursday, June 6, 2013 11:17 PM

Answers

  • The recommended code works as-is for input and select items.

    To de-activate a button, check-box, flip-switch, etc., you'll probably have better luck using a specific selector as opposed to the generic element.  You'll also want to make sure your button has the ability to be in the disabled state if not defined specifically in its class.

    $(":button:contains('<<BtnToBeDisabled>>')").prop("disabled", true).addClass("ui-state-disabled");

    Friday, June 7, 2013 6:13 PM

All replies

  • It is possible to do this in the postRender's assigned function as you started to do.  The function's element is the DOM node object, but it is not a jQuery object.  You will be able to use .attr() once you have done the following:

    jQuery(element).attr('disabled', true);

    Friday, June 7, 2013 6:17 AM
  • I have tried:

    $(element).attr('disabled', true);
    $(element).parent().attr('disabled', true);

    None of them work. I can see the HTML in the browsers and the div is disabled. But I still can click on the item and it fires the event.

    When I click on the item it goes to another hidden tab. I need to disable some items so they can not go to the hidden tab. It is disabling the items with that code.

    Friday, June 7, 2013 3:09 PM
  • The recommended code works as-is for input and select items.

    To de-activate a button, check-box, flip-switch, etc., you'll probably have better luck using a specific selector as opposed to the generic element.  You'll also want to make sure your button has the ability to be in the disabled state if not defined specifically in its class.

    $(":button:contains('<<BtnToBeDisabled>>')").prop("disabled", true).addClass("ui-state-disabled");

    Friday, June 7, 2013 6:13 PM