Reputation:
I use jqrrid 4.6.0
- @license jqGrid 4.6.0 - jQuery Grid
- Copyright (c) 2008, Tony Tomov, [email protected]
The thing is after I add new record, the dialog is not closed.
$(gridSelector).jqGrid('navGrid', pagerSelector,
{
//navbar options
edit: true,
editicon: 'ace-icon fa fa-pencil blue',
add: true,
addicon: 'ace-icon fa fa-plus-circle purple',
del: true,
delicon: 'ace-icon fa fa-trash-o red',
search: true,
searchicon: 'ace-icon fa fa-search orange',
refresh: true,
refreshicon: 'ace-icon fa fa-refresh green',
view: true,
viewicon: 'ace-icon fa fa-search-plus grey'
},
{
//edit record form
//closeAfterEdit: true,
//width: 700,
recreateForm: true,
mtype: 'PUT',
onclickSubmit: function (params, postdata) {
params.url = API_URL;
},
beforeShowForm: function (e) {
var form = $(e[0]);
form.closest('.ui-jqdialog').find('.ui-jqdialog-titlebar').wrapInner('<div class="widget-header" />');
styleEditForm(form);
}
},
{
//new record form
//width: 700,
closeAfterAdd: true,
recreateForm: true,
viewPagerButtons: false,
mtype: 'POST',
onclickSubmit: function (params, postdata) {
params.url = API_URL + 'PostVendor';
},
afterSubmit: function (response, postdata) {
var userKey = JSON.parse(response.responseText).UserKey;
alert("The password you created for the new vendor is\n\n" + userKey);
},
beforeShowForm: function (e) {
var form = $(e[0]);
form.closest('.ui-jqdialog').find('.ui-jqdialog-titlebar')
.wrapInner('<div class="widget-header" />');
styleEditForm(form);
}
}
But I have closeAfterAdd: true
in POST
part.
Upvotes: 0
Views: 852
Reputation: 221997
The reason of your problem is very easy, but it's difficult to locate. You included afterSubmit
, which you implemented in the wrong way. The callback function have to return array with at least one element. Typically the callback returns
[true]
which means that jqGrid should interpret the server response as successful. If analyzing of the content of the server responds shows that the server side processing of the request failed then the callback afterSubmit
should return the result like
[false, "It's <em>Important</em> error on the server side!!!"]
Your code return undefined
and I suppose that you will see an exception in processing the next statement after calling afterSubmit
callback, because res[0]
will be used with undefined
variable res
.
Upvotes: 1