0

I have been using inlineNav method for inline add as follows.

jQuery("#mygrid").jqGrid("inlineNav", "#mygrid_pager1",{"addParams":{"position":"last","addRowParams":{"keys":true}}});

It works great. Now, I need to reload the grid after adding a new row. I've tried the following and it didn't work.

jQuery("#mygrid").jqGrid("inlineNav", "#mygrid_pager1",{"addParams":{"position":"last","addRowParams":{"keys":true, "successfunc":"function(id){$("mygrid").trigger("reloadGrid");"}}});

Any pointers are appreciated!

devXen
  • 3,013
  • 3
  • 35
  • 44

3 Answers3

3

First of all the value of successfunc should be the function and not the string (see in your current code "successfunc":"...")

I would recommend you to try to add the same settings to both addParams.addRowParams and to editParams options of inlineNav. Moreover I would recommend you to place $(this).trigger("reloadGrid") from successfunc inside of setTimeout to be sure that reloading will be started after the standard processing of saving of the row.

So the code could be about the following:

var editOptions = {
        keys: true,
        successfunc: function () {
            var $self = $(this);
            setTimeout(function () {
                $self.trigger("reloadGrid");
            }, 50);
        }
    };

$("#mygrid").jqGrid("inlineNav", "#mygrid_pager1", {
    addParams: {
        position: "last",
        addRowParams: editOptions
    },
    editParams: editOptions
});
Oleg
  • 220,925
  • 34
  • 403
  • 798
  • I'm gonna give it try. Thanks, Oleg. I've also tried reloadAfterSubmit and set it to true, and I wonder why that didn't work neither. – devXen Sep 30 '13 at 23:16
  • @ToadyMores: You are welcome! Do you set `reloadAfterSubmit` only for add or for both add and edit operations? The problem is that "Save" button of inlineNav don't distinguish the options good enough and can use edit options (`editParams`) even you added new row. Some from the bugs are already fixed in the code of jqGrid on github. – Oleg Sep 30 '13 at 23:22
  • You are right, I made a silly mistaken by surrounding the function with quotes. Once the quotes are moved, it works! I added setTimeout as well based on your code. – devXen Oct 02 '13 at 01:04
0

I think the easiest way is after you finish add something, call reload function separately like jQuery("#myGrid").reload();

Stephanie Yang
  • 252
  • 1
  • 4
  • 13
0
$("#list").jqGrid('setGridParam',{datatype:'json'}).trigger('reloadGrid');
RackM
  • 449
  • 7
  • 26