如何将数据从我的JQGrid发送到我的查询删除一行? [英] How do I send data from my JQGrid to my query to delete a row?

查看:127
本文介绍了如何将数据从我的JQGrid发送到我的查询删除一行?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我无法从我的JQGrid删除一行,因为我不知道如何发送我需要的数据保存MySQL的文件。我使用ColdFusion。

I am unable to delete a row from my JQGrid because I can't figure out how to send the data I need to the file that holds the MySQL. I am using ColdFusion.

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

In my JQGrid file, my editurl parameter is set as such:

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


$ b b

在我的process_delete.cfc文件中,我拥有我的MySQL查询,我有这样:

In my process_delete.cfc file, that holds my MySQL queries, I have this:

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

我知道MySQL正在被访问 - 没有问题。此外,该区域是从URL精确填充。没有问题。问题是,我不知道如何访问我想删除的行的数据,以填充Field1和Field2,有效地完成查询。任何人可以帮助?谢谢。

I know that the MySQL is being reached - no problems there. Also, the region is populated just fine from the URL. No problems there. The problem is that I can't figure out how to access the data from the row I'm trying to delete in order to populate Field1 and Field2, effectively completing the query. Can anyone help? Thanks.

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

For Delete I have the following code:

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, ""]
            }

code> rowid 在警告消息框中,我得到null回来,所以也许这是我的问题源于。

When I display the rowid in an alert message box, I get "null" back, so maybe that's where my problem stems from.

推荐答案

您可以使用属性 field1 和<$ c $>使用 delData c> field2 定义为函数或使用 onclickSubmit beforeSubmit 修改在DELETE操作中使用的 URL 或使用 serializeDelData 回调。最好的方法可以取决于你使用的其他选项(例如取决于用于删除操作的 mtype )。在答案中,我包括了对其他答案的引用,详细显示了所有方式。

You can either use delData with the properties field1 and field2 defined as functions or to use onclickSubmit or beforeSubmit in which you can dynamically modify the URL used in the DELETE operation or to use serializeDelData callback. The best way could depend on other options which you use (for example depends on mtype used for Delete operation). In the answer I included the references to other answers which shows all the ways in details.

例如,您可以使用

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
}

这篇关于如何将数据从我的JQGrid发送到我的查询删除一行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆