Click here to Skip to main content
15,171,576 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi All,

I am a new bee in Jq Grids so here is problem . I have one jqGrid and there are three checkbox in each row of grid... Now my requirment is only one checkbox whould be checked corresponding to each row... Below is my code How I can achieve this functionality

JavaScript
 $("#BatchQCGrid").jqGrid({
        datatype: 'json',
        colNames: ['Batch ID:"' + accessionId + '"', 'Pos QC', 'Neg QC', 'KeyString', 'Pass', 'Fail', 'Repeat?', 'Comments'],
        colModel: [
            { name: 'Assay', index: 'Assay', width: 50, align: 'center' },
            { name: 'PosQC', index: 'PosQC', width: 50, align: 'center' },
            { name: 'NegQC', index: 'NegQC', width: 50, align: 'center' },
            { name: 'KeyString', index: 'KeyString', width: 100, hidden: true, align: 'center' },
            { name: 'Pass', index: 'Pass', formatter: batchPassCheckbox, width: 50, align: 'center' },
            { name: 'Fail', index: 'Fail', formatter: batchFailCheckbox, width: 50, align: 'center' },
            { name: 'Repeat', index: 'Repeat', formatter: batchRepeatCheckbox, width: 50, align: 'center' },
            { name: 'Comments', index: 'Comments', formatter: batchComments, Width: 300, align: 'center' }
            ],
        multiselect: false,
        emptyrecords: "No records to view",
        pgbuttons: false,
        viewrecords: true,
        loadonce: true,
        altRows: true,
        height: 'auto'
    });

  dArray = "{";
    dArray += "'caseNo': '" + caseno + "',";
    dArray += "'rqstMsg': '" + hdnsession + "'";
    dArray += "}";
    $.ajax({
        type: "POST",
        url: "../../../../ClientSide-Services/Assay.asmx/GetBatchQcData",
        data: dArray,
        contentType: "application/json; charset=utf-8",
        dataType: "json",
        async: false,
        success: function(response) {

            if (response.d != '{"Table" : ]}') {
                var gd = eval('(' + response.d + ')');
                for (row in gd) {
                    $("#BatchQCGrid").jqGrid('addRowData', row, gd[row]);
                }
                $("#BatchQCGrid").trigger("reloadGrid");
            }
            else {
                $("#BatchQCGrid").jqGrid("clearGridData", true).trigger("reloadGrid");
            }
        },
        error: function(response) {
            alert(response.responseText);
        }
    });

function batchPassCheckbox(cellValue, options, rowobject, action) {
    var checked = cellValue == 'true' ? " checked='checked' " : "";
    var a = "<input type='checkbox' " + checked + " value='" + cellValue + "' id=chkBatchPass />";
    return a;
}
function batchFailCheckbox(cellValue, options, rowobject, action) {
    var checked = cellValue == 'true' ? " checked='checked' " : "";
    var a = "<input type='checkbox' " + checked + " id='chkBatchFail' value='" + cellValue + "'></input>";
    return a;
}
function batchRepeatCheckbox(cellValue, options, rowobject, action) {
    var checked = cellValue == 'true' ? " checked='checked' " : "";
    var a = "<input type='checkbox' " + checked + " id='chkBatchRepeat'  value='" + cellValue + "'></input>";
    return a;
}


My requirement is suppose if I click first Pass check-box after that I click on Fail Check-box than Pass check box should be unchecked means only one check boc should be checked for each row in the grid... Help with code would be appreciated please help me .....
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900