如何在jQgrid中使用“formDeleting”时添加要发送到服务器的额外参数?

时间:2018-01-16 16:43:13

标签: javascript jquery jqgrid free-jqgrid

当我尝试删除jQgrid中的一行或多行时,我需要发送一个额外的参数。我找到了以下内容:

但那些是一年/两年的答案,我认为jQgrid自那时起已发生变化。我使用jQgrid中的formDeleting选项定义如下:

formDeleting: {
    url: '/ajax/forms/delete',
    delicon: [true, "left", "fa-scissors"],
    cancelicon: [true, "left", "fa-times"],
    width: 320,
    caption: 'Delete form',
    msg: 'Are you sure you want to delete this form?',
    beforeShowForm: function ($form) {
        var rowids = $form.find("#DelData>td").data("rowids");

        if (rowids.length > 1) {
            $form.find("td.delmsg").html('Are you sure you want to delete all the selected forms?');
        }
    },
    afterComplete: function (response, postdata, formid) {
        if (response.responseText === "true") {
            alert("The form was deleted successfully.", "Information");
        } else {
            alert("Something went wrong, the form could not be deleted.", "Error");
        }
    }
}

如何在请求中添加额外参数,以便在后端获取?

1 个答案:

答案 0 :(得分:0)

我建议您在onclickSubmit附近使用the answer回调,但要将onclickSubmit回调的代码放在formDeleting内。在formDeleting内部formDeletingserializeDelData的使用也是可能的,但如果发布的数据发生更深层次的变化,则使用它会更好,例如使用情况例如,JSON.stringify