从jqgrid的行获取rowID

时间:2012-10-16 08:09:15

标签: asp.net-mvc-3 jqgrid checkbox jqgrid-asp.net

在我的asp.net MVC 3应用程序中使用Jqgrid作为我的网格。它包含一个复选框,我按以下方式管理事件

 $("#list").find('input[type=checkbox]').live('change', function () {
                if ($(this).is(':checked')) {
                    var _row = $(this).parent().parent();
}
});

我使用$(this).parent().parent()我想要get the id of the _row。我怎样才能获得身份证?有没有方法请分享

2 个答案:

答案 0 :(得分:2)

这应该可以解决问题:

$('#list').find('input[type=checkbox]').live('change', function () {
    if ($(this).is(':checked')) {
        var row = $(this).parent().parent();
        var rowId = row.attr('id');
    }
});

如果您使用jqGrid的idPrefix选项的默认值(这是空字符串),否则id将以此选项的值为前缀。

答案 1 :(得分:0)

在选择行上,您可以获取所选行的ID。实际上,当您选中一个复选框时,您也会选择一行:

onSelectRow: function(id){
yourId = $("#yourGrid").jqGrid('getGridParam', 'selrow');
alert("The id of checked row is: "+yourId);
}