0

I'm using guriddo jqGrid 5.2.1

I've followed the answers provided to these questions:

But the editData I've defined is not getting sent to the endpoint.

Here is the code in my jqgrid pager definition:

$('#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 is defined outside of the jqGrid and jqGridPager functions, at the page level. I tried sending a value of 1, but that doesn't work either. I suspect I've missed something simple, but I can't figure out what.

Michael Sobczak
  • 1,045
  • 1
  • 24
  • 45

2 Answers2

1

You place the editData parameter on the wrong place. The options of navGrid are very bad and one can made easy errors. I described the problem in detailed in the wiki article of free jqGrid fork, which I develop.

Currently you placed editData in the options of navGrid instead of placing it in the options of Edit/Add, which are the options of editGridRow. The problem is solved in free jqGrid, but if you do prefer to use commercial version of Guriddo jqGrid JS then I would recommend you to rewrite your code in the following way:

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);
Oleg
  • 220,925
  • 34
  • 403
  • 798
1

I think that the better approach is to read first the documentation of Guriddo jqGrid, which will guide you where to put the parameter.

Tony Tomov
  • 3,122
  • 1
  • 11
  • 18
  • I hadn't realized that there was an update to the documentation. I kept referring to the old jqgrid wiki. Thanks for letting me know! – Michael Sobczak Jul 08 '17 at 12:27