gpt4 book ai didi

jquery - 如何将数据从 JQGrid 发送到查询以删除行?

转载 作者:行者123 更新时间:2023-12-01 06:36:59 25 4
gpt4 key购买 nike

我无法从 JQGrid 中删除行,因为我不知道如何将所需的数据发送到保存 MySQL 的文件。我正在使用 ColdFusion。

在我的 JQGrid 文件中,我的 editurl 参数设置如下:

editurl: url+"process_delete.cfc?method=process_delete&region="+region,

在保存 MySQL 查询的 process_delete.cfc 文件中,我有以下内容:

DELETE FROM awesome_table
WHERE region = '#region#' AND Field1 = '??????' AND Field2 = '???????'

我知道正在访问 MySQL - 没有问题。此外,该区域也可以通过 URL 很好地填充。那里没有问题。问题是我无法弄清楚如何访问我尝试删除的行中的数据,以便填充 Field1 和 Field2,从而有效地完成查询。有人可以帮忙吗?谢谢。

对于删除,我有以下代码:

jQuery.jgrid.del = {
caption: "Delete Item",
msg: "Delete record?",
bSubmit: "Delete",
bCancel: "Cancel",
beforeSubmit: function(postdata, formid) {
var rowid = $("#mygrid").getGridParam('selrow');
$("#mygrid").jqGrid('saveRow',rowid,false,'clientArray');
var rowvalues = $("#mygrid").getRowData(rowid);
return [true, ""]
}

当我在警报消息框中显示 rowid 时,我得到“null”,所以也许这就是我的问题的根源。

最佳答案

您可以将 delData 与定义为函数的属性 field1field2 一起使用,也可以使用 onclickSubmitbeforeSubmit,您可以在其中动态修改 DELETE 操作中使用的 URL 或使用 serializeDelData 回调。最好的方法可能取决于您使用的其他选项(例如取决于用于删除操作的 mtype)。在 the answer我引用了其他答案,详细说明了所有方法。

例如,您可以使用

onclickSubmit: function (options, rowid) {
// we suppose that use don't use multiselect: true option
// in the case rowid parameter if the string with the id of the
// deleted row

// we can get the data about the deleted row with respect of
// getCell, getLocalRow or getRowData methods
var rowData = $(this).jqGrid("getRowData", rowid);

// now we can modify the URL used in the Delete operation
options.url += "?" + $.param({
field1: rowData.field1,
field2: rowData.field2
});

return {}; // you can return additional data which will be sent to the server
}

关于jquery - 如何将数据从 JQGrid 发送到查询以删除行?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12324279/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com