【问题标题】:jqgrid: editData not being sent to serverjqgrid:editData没有被发送到服务器
【发布时间】:2017-07-07 18:50:46
【问题描述】:

我正在使用 guriddo jqGrid 5.2.1

我已按照以下问题提供的答案进行操作:

但是我定义的 editData 没有被发送到端点。

这是我的 jqgrid 寻呼机定义中的代码:

$('#jqGrid').navGrid('#jqGridPager',
            // the buttons to appear on the toolbar of the grid
            { edit: true, 
                add: true, 
                del: true, 
                search: false, 
                refresh: false, 
                view: false, 
                position: "left", 
                cloneToTop: false,
                mtype: 'POST',
                editData: {
                    mediaPlanId : function() { return mpId; }
                }},
            // options for the Edit Dialog
            {
                editCaption: "Edit Item",
                recreateForm: true,
                checkOnUpdate : true,
                checkOnSubmit : true,
                closeAfterEdit: true,
                errorTextFormat: function (data) {
                    return 'Error: ' + data.responseText;
                }
            },
            // options for the Add Dialog
            {
                closeAfterAdd: true,
                recreateForm: true,
                errorTextFormat: function (data) {
                    return 'Error: ' + data.responseText;
                }
            },
            // options for the Delete Dailog
            {
                errorTextFormat: function (data) {
                    return 'Error: ' + data.responseText;
                }
            }

    );

mpId 在页面级别的 jqGrid 和 jqGridPager 函数之外定义。我尝试发送一个值 1,但这也不起作用。我怀疑我错过了一些简单的东西,但我不知道是什么。

【问题讨论】:

  • 你用的是哪个版本?
  • 感谢您指出这一点!我更新了问题以包含它。

标签: jquery jqgrid


【解决方案1】:

您将editData 参数放置在错误的位置。 navGrid 的选项非常糟糕,很容易出错。我在我开发的free jqGrid fork 的the wiki article 中详细描述了这个问题。

目前您将editData 放在navGrid 的选项中,而不是放在editGridRow 的选项中的编辑/添加选项中。这个问题在免费的 jqGrid 中得到了解决,但是如果你更喜欢使用商业版的 Guriddo jqGrid JS,那么我建议你用以下方式重写你的代码:

var myErrorFunc = function (data) {
        return 'Error: ' + data.responseText;
    },
    addEditFormOptions = {
        editCaption: "Edit Item",
        recreateForm: true,
        checkOnUpdate : true,
        checkOnSubmit : true,
        closeAfterEdit: true,
        closeAfterAdd: true,
        editData: {
            mediaPlanId : function() { return mpId; }
        },
        errorTextFormat: myErrorFunc
    },
    delOptions = {
        errorTextFormat: myErrorFunc
    };

$('#jqGrid').navGrid('#jqGridPager', { search: false, refresh: false },
    addEditFormOptions, addEditFormOptions, delOptions);

【讨论】:

    【解决方案2】:

    我认为更好的方法是先阅读documentation of Guriddo jqGrid,它将指导您将参数放在哪里。

    【讨论】:

    • 我没有意识到文档有更新。我一直在参考旧的 jqgrid wiki。谢谢你告诉我!
    猜你喜欢
    • 2021-04-28
    • 2022-10-24
    • 2021-06-04
    • 2019-05-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多