0

I had a jqGrid working with inline editing with a dedicated script just for this grid. I am trying to organize and consolidate the server scripts, so now I wish to use a new script for inline editing on the server. To use this new script I need to pass the script an extra POST variable when editing inline. I can't figure out how to POST additional data to server while editing inline.

With form editing I use the editData attribute to include addition POST data with the edit form. I have read in the jqGrid docs that I may be able to pass addition POST data with the extraparams parameter. I just can't seem to get the syntax right.

This is what I have, and it is not working:

$('#list').editRow(
        id,
        true,
        function(){
            $('input[name=customer]').autocomplete({source:customerlist});
            today = new Date();
            $('input[name=date]').val(today.getFullYear() + '-' + (today.getMonth()+1) + '-' + today.getDate());
        },
        extraparams={
            'arg1':'daily_folding_reports'
        }
    );

Where list is the ID of the grid. The function to add autocomplete is firing correctly on EDIT, but I am not incorporating the extraparams correctly. What is the correct syntax for this?

Thanks!

jeffery_the_wind
  • 17,048
  • 34
  • 98
  • 160

1 Answers1

2

If you use the position form of editRow then the call should be like the following

$("#list").jqGrid('editRow', id,
    true,
    function () {
        $('input[name=customer]').autocomplete({source:customerlist});
        today = new Date();
        $('input[name=date]').val(today.getFullYear() + '-' +
            (today.getMonth()+1) + '-' + today.getDate());
    },
    null,
    null,
    { arg1: 'daily_folding_reports' });

I personally prefer another for of the editRow usage which can reduce the number of null parameters:

$("#list").jqGrid('editRow', id, {
    keys: true,
    oneditfunc: function () {
        $('input[name=customer]').autocomplete({source:customerlist});
        today = new Date();
        $('input[name=date]').val(today.getFullYear() + '-' +
            (today.getMonth()+1) + '-' + today.getDate());
    },
    extraparam: { arg1: 'daily_folding_reports' }
});

I find the form more readable (see the answer for example).

Community
  • 1
  • 1
Oleg
  • 220,925
  • 34
  • 403
  • 798
  • I realize this is an old post, but would it be possible to come back and re-answer some of these based on jqGrid v4.x.x's new API? – DevlshOne May 20 '14 at 16:54
  • @DevlshOne: There are too many options, so I don't full understand what you mean. There are many form of usage of inline editing: direct call of `editRow` (like here), usage of `formatter: "actions"` and usage of `inlineNav`. Moreover one can use `extraparam` with properties defined as function (see [here](http://stackoverflow.com/a/13227472/315935), [here](http://stackoverflow.com/a/14835289/315935), [here](http://stackoverflow.com/a/8512693/315935) and other) or one can use `serializeRowData` callback. It's just difficult to describe **all possible cases** in one answer. – Oleg May 20 '14 at 17:15
  • I appreciate the fact that there are so many options and ways to answer this so I have posted my own specific situation and question. Thanks – DevlshOne May 20 '14 at 17:45