【问题标题】:jqGrid inline delete: selected row "selrow" is incorrectjqGrid内联删除:所选行“selrow”不正确
【发布时间】:2012-04-19 14:59:14
【问题描述】:

我有一个内联删除按钮,我想将更多数据附加到删除消息弹出窗口,如下所示: "删除代码 = 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 要么为空,要么获取先前选择的行而不是当前选择的行!

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

感谢任何帮助

【问题讨论】:

  • 你能告诉我们你用来创建删除按钮的代码吗?

标签: jqgrid


【解决方案1】:

我想您使用的是我在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")
}

【讨论】:

  • 感谢奥列格,照顾它。
  • 当我们这样做的时候,有没有办法让删除对话框在窗口中居中?我可以使用stackoverflow.com/questions/210717/… 将其居中,但对于长网格,它总是会捕捉到窗口的顶部
  • @AE:有很多方法可以实现这一点。例如,从the answer 查看the demo。您可以在another demo 上从the answer 看到另一种将对话框居中的可能性。将 div(对话框)放置在网格 可见 部分的中心的另一种方法是 here。您可以对任何对话使用相同的想法。
  • 我尝试了这些解决方案,它已经居中,但它显示对话框然后视口捕捉到窗口顶部!
  • @AE:这不是你需要的吗?您希望如果网格很长(有很多行或很多列),则会出现对话框以便用户看到它。不是这样吗?
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2011-11-03
  • 2011-07-24
  • 2015-07-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多