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

How to add an extra parameter to be sent to the server while using "formDeleting" in jQgrid?

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

但那些是 one/two 年前的答案,我认为 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");
        }
    }
}

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

我建议您在 formDeleting 内部使用 onclickSubmit callback close to , but to place the code of the onclickSubmit callback inside of formDeleting. The usage of serializeDelDataformDeleting 内部也可以,但最好使用它以防发布的内容发生更深层次的变化数据,例如 JSON.stringify 的用法。