禁用下拉上点击单选按钮(Disable the Dropdown on clicking on Ra

2019-11-03 02:30发布

我在jqGrid的制作单选按钮,现在我想在单选按钮的单击事件禁用另一列

{ 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;
    }
});

从那以后,我使用的一些功能来生成单选按钮的HTML

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);
        }
    }
}

我想在单选按钮的列表中禁用任何单选按钮的点击此列,

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

Answer 1:

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


文章来源: Disable the Dropdown on clicking on RadioButton