Disable the Dropdown on clicking on RadioButton

2019-08-28 06:26发布

问题:

I am making a RadioButton in JqGrid , now i want to disable another column on the click event of radiobutton

{ name: 'Result', index: 'Result', width: 30, editable: true, formatter: 'dynamicText',
                    edittype: 'custom', editoptions: { custom_element: radioelem, custom_value: radiovalue }
 },
$.extend($.fn.fmatter, {
    dynamicText: function (cellvalue, options, rowObject) {
        var returnValue = ""
        if (cellvalue == '1') {
            returnValue = 'S';
        }
        else if (cellvalue == '3') {
            returnValue = 'N/A';
        }
        else if (cellvalue == '2') {
            returnValue = 'US';
        }
        return returnValue
    }
});

$.extend($.fn.fmatter.dynamicText, {
    unformat: function (cellValue, options, elem) {
        var text = $(elem).text();
        return text === ' ' ? '' : text;
    }
});

After that i used Some functions to generate the HTML for radioButtons

function radioelem(value, options, rowobject) {
    var sradio = '&nbsp&nbsp<input type="radio"  value="1" name="receivednaradio"/>';
    var sradioChecked = '&nbsp&nbsp<input type="radio" checked="checked" value="1" name="receivednaradio"/>';
    var breakline = 'S &nbsp&nbsp&nbsp&nbsp';
    var usradio = '<input type="radio"  value="2" name="receivednaradio"/>';
    var usradioChecked = '<input type="radio" checked="checked" value="2" name="receivednaradio"/>';
    var endnaradio = 'US &nbsp&nbsp&nbsp&nbsp';
    var naradio = '<input type="radio"  value="3" name="receivednaradio"/>';
    var naradioChecked = '<input type="radio"  checked="checked" value="3" name="receivednaradio"/>';
    var end = '<span>N/A</span>';
    if (value == 'S') {
        var radiohtml = sradioChecked + breakline + usradio + endnaradio + naradio + end;
        return radiohtml;
    } else if (value == 'US') {
        var radiohtml = sradio + breakline + usradioChecked + endnaradio + naradio + end;
        return radiohtml;
    }
    else if (value == 'N/A') {
        var radiohtml = sradio + breakline + usradio + endnaradio + naradioChecked + end;
        return radiohtml;
    }
    else {
        return sradio + breakline + usradio + endnaradio + naradio + end;
    }
}
function radiovalue(elem, operation, value) {
    if (operation === 'get') {
        var newValue = 0;
        $(elem).each(function () {
            if ($(this).is(":checked"))
                newValue = this.value;
            return;
        });
        return newValue;
    } else if (operation === 'set') {
        if ($(elem).is(':checked') === false) {
            $(elem).filter('[value=' + value + ']').attr('checked', true);
        }
    }
}

I want to disable this column on the click of any of the radiobutton in the list of RadioButtons ,

{
                    name: 'AuditLevel', index: 'AuditLevel', align: 'center', width: 15, editable: true, edittype: 'select',
                    editoptions: { value: { value: " : ;1:Level1; 2:Level2;3: Level3" } }
                },

回答1:

if (($("#radioButtonId").is(':checked')) ){
$('#AuditLavel').attr("disabled",true)
}
else
{
$('#AuditLavel').attr("disabled",false)
}