correct syntax for passing additional POST data (extraparams) to server when inline editing jqGrid

StackOverflow https://stackoverflow.com/questions/12431628

سؤال

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!

هل كانت مفيدة؟

المحلول

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).

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top