jqGrid内联删除:选中的行“selrow”不正确

时间:2012-04-05 20:57:41

标签: jqgrid

我有一个内联删除按钮,我想在删除消息弹出窗口中添加更多数据,如下所示: “删除代码= 7的所选行?”

我在delOptions中使用以下内容:

beforeShowForm: function ($form) {
var sel_id = $("#list").jqGrid('getGridParam', 'selrow');
$("td.delmsg", $form[0]).html("Delete record with <b>code=" + $("#list").jqGrid('getCell', sel_id, 'cd') + "</b>?");}

问题是如果我在没有先单击行的任何部分的情况下点击删除按钮,则selrow为null或者它之前选择的行不是当前所选的行!

如何在点击垃圾桶图标时选择行?

感谢任何帮助

1 个答案:

答案 0 :(得分:3)

我想您使用我在the old answer中发布的示例。它是在使用导航栏中的删除按钮(表单编辑部分)的情况下编写的。

“删除”对话框中有一个隐藏的行可以帮助您。试试这个

beforeShowForm: function ($form) {
    // get comma separated list of ids of rows which will be delete
    // in case of multiselect:true grid or just id of the row.
    // In the code below we suppose that single row selection are used
    var idOfDeletedRow = $("#DelData>td:nth-child(1)").text();
    $form.find("td.delmsg").eq(0)
        .html("Delete record with <b>code=" +
            $(this).jqGrid('getCell', idOfDeletedRow, 'cd') + "</b>?");
    // REMARK: in old versions of jqGrid you can't use $(this) and
    //         will have to use something like $("#list")
}
相关问题