如何在jQGrid中获取多个rowID?

时间:2018-07-04 08:46:13

标签: jquery jqgrid-formatter

enter image description here

当单击多个复选框时,然后如何在jqGrid中获取多个RowID

  • 代码:

    function BindMainGrid(rowDataMain){     调试器;     $ grid = $(“#GetpassTable”);     $ grid.jqGrid({         loadError:函数(xhr,状态,错误){             alert('load error:'+ error);         },         colNames:[“邮件”,“ GetPassID”,“ IMNumber”,“ UserID”,“项目说明”,“ AssetTag”,“单元”,“质量”,“运动原因”,“申购人”,“待携带”通过“,”从位置“,”从子位置“,”到位置“,”到子位置“]]         colModel:[

         { name: 'Mail', index: 'Mail', sorttype: 'text', width: '60px', formatter: RenderMail },
            { "name": "GetPassID", "index": "GetPassID", "width": "150", hidden: true },
    
            { "name": "IMNumber", "index": "IMNumber", "width": "150"},
             { "name": "UserID", "index": "UserID", "width": "150" },
             { "name": "Item_Description", "index": "Item_Description", "width": "300" },
              { "name": "AssetTag", "index": "AssetTag", "width": "500" },
    
               { "name": "Unit", "index": "Unit", "width": "150" },
             { "name": "Quanity", "index": "Quanity", "width": "150" },
             { "name": "Reason_For_Movement", "index": "Reason_For_Movement", "width": "350" },
              { "name": "Requisitioner", "index": "Requisitioner", "width": "200" },
    
            { "name": "ToBeCarriedBy", "index": "ToBeCarriedBy", "width": "150" },
             { "name": "FromLocation", "index": "FromLocation", "width": "150" },
              { "name": "FromSubLocation", "index": "FromSubLocation", "width": "150" },
    
               { "name": "ToLocation", "index": "ToLocation", "width": "150" },
              { "name": "ToSubLocation", "index": "ToSubLocation", "width": "150" },
    
    
        ],
    
    
        data: rowDataMain,
        datatype: "local",
        editurl: 'Project Details',
        gridview: true,
        pgbuttons: true,
        rowList: [10, 20, 30, 40],
        rownum: 10,
        pager: '#GetpassPager',
        datapage: true,
        viewrecords: true,
        autowidth: true,
        height: "280px",
        loadtext: "Loading...",
        scroll: false,
        pageable: true,
        pagerpos: 'center',
        caption: "Get pass Generation",
        multiselect: false,
        loadonce: false,
        forceFit: false,
        ignoreCase: true,
        jsonReader: {
            page: function (obj) { return 1; },
            total: function (obj) { return 1; },
            records: function (obj) { return obj.d.length; },
            root: function (obj) { return obj.d; },
            repeatitems: false,
            id: "0"
        },
        shrinkToFit: false,
        loadComplete: function (data) {
    
        },
    }).navGrid("#GetpassPager", { edit: false, add: false, del: false }, {}, {}, {}, { modal: true, multipleSearch: true })
    

    }

    function RenderMail(cellValue, options, subrowData, rowObject) {
    var radioHtml = '<input style="width:25px" type="Checkbox" value=' + cellValue + ' name="Checkid" onclick="chk(\'' + options.subgrid_id + '\')"></input>';
    
    
    return radioHtml;
    

    }

    function chk(rowId){

    }

1 个答案:

答案 0 :(得分:0)

尝试使用JQUERY

$('#GetpassTable input:checkbox').each(function(i){

console.log($(this).prop('checked')+' '+i);
})

要获取复选框上的ID,请尝试此操作

$(document).on('click','#GetpassTable tbody input:checkbox',function(){
console.log('clicked id : '+$(this).closest('tr').prop('id'));
});

如果遇到任何错误,请查看控制台窗口