Ramana
Ramana

Reputation: 11

Close Add/Edit forms for jqgrid with afterSubmit function

I am newbie in using jqgrid.

I am using afterSubmit: function to reload the grid for add/edit changes,afterSubmit: function is working fine with updated data. But Add record and Edit forms are not getting closed. I have used this options (closeAfterEdit:true,closeAfterAdd:true) not getting closed. My problem with where exactly use this options confussing.

Without afterSubmit: function both forms are getting closed. Sorry! for my bad english. Please find the bellow navGrid code:

   $("#companyList").jqGrid('navGrid',"#pager2",{add:true,edit:true,del:true,refresh:false,
                    beforeRefresh: function(){
                      $("#companyList").jqGrid('setGridParam',{datatype:'xml'}).trigger('reloadGrid');
                    }},
                    {
                     afterSubmit: function() {
                       $("#companyList").jqGrid('setGridParam'{datatype:'xml'}).trigger('reloadGrid');
                         return [true,'',false]; // no error and no new rowid
                        }
                    },{
                       afterSubmit: function() {
                          $("#companyList").jqGrid('setGridParam',{datatype:'xml'}).trigger('reloadGrid');
                       return [true,'']; // no error
                        }
                    },
                    editParam = {
                         editData:{myparam:function(){return "myval";}},
                         reloadAfterSubmit: true,
                         editCaption:'Edit Record',
                         bSubmit:'Save',
                         url:'<%=request.getContextPath()%>/CompanyJqGrid? q=1&action=addData',
                         closeAfterEdit:true,
                         viewPagerButtons:false
                     },{closeAfterAdd:true});

Upvotes: 1

Views: 10072

Answers (5)

Willie Cheng
Willie Cheng

Reputation: 8253

in fact it is very easy to do it , you just need to add one command line like as following code

closeAfterEdit:true

 $('#jQGridDemo').jqGrid('navGrid', '#jQGridDemoPager',
    {
      edit: true,
      add: false,
      del: false,
      search: false,
    },
    {   //EDIT
       closeOnEscape: true,//Closes the popup on pressing escape key
       closeAfterEdit: true,
       //afterSubmit: function (response, postdata) {
       //  }
    }

........

Upvotes: 0

user789
user789

Reputation: 1

This resolved the issue for me;

afterSubmit: function (resp, postdata) 
{
   return [true,"",null];
}, closeAfterEdit: true

Upvotes: 0

Yaqoob Al-Shuaibi
Yaqoob Al-Shuaibi

Reputation: 93

the correct syntax for afterSubmit is:

afterSubmit : function(response, postdata)
{
   …
  return [success,message,new_id]
}

Upvotes: 0

zbacsi
zbacsi

Reputation: 148

These are the arguments of the navGrid method:

.navGrid('#gridpager',{parameters}, prmEdit, prmAdd, prmDel, prmSearch, prmView);

To close the dialog windows both after edit and after add a row, you sholud add closeAfterEdit:true to the prmEdit, and closeAfterAdd:true to the prmAdd object. Like here:

$("#companyList").jqGrid('navGrid',"#pager2",{add:true,edit:true,del:true,refresh:false,
        beforeRefresh: function(){...}},
    {//prmEdit
        closeAfterEdit:true,
        afterSubmit: function() {...}
    },
    {//prmAdd
        closeAfterAdd:true,
        afterSubmit: function() {...}
    }
)

Upvotes: 0

Meenakshi
Meenakshi

Reputation: 121

which jqgrid verion are you using. I am using 3.6+, and this works for me

$("#gUserGrid").jqGrid('navGrid','#pagergUserGrid',{add:true,edit:true,del:true,search:true}, //NAVIGATION BAR
        {   
            jqModal:true,
            savekey: [true,13], 
            navkeys: [true,38,40],
            width: 500,  
            reloadAfterSubmit:true 


        }, // edit options 
        {   jqModal:true
            ,reloadAfterSubmit:true

        }, // add options 
        {
                       reloadAfterSubmit:true}, //del options
        {  
        } // search options

        );

Upvotes: 0

Related Questions