22550

Close add dialog after submit

Question:

I use jqrrid 4.6.0

<blockquote> <ul><li>@license jqGrid 4.6.0 - jQuery Grid</li> <li>Copyright (c) 2008, Tony Tomov, tony@trirand.com</li> </ul></blockquote>

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.

Answer1:

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.

Recommend

  • How to add close button to the event block in Fullcalendar
  • Sending mail works from localhost but not from remote server
  • How to pass jQuery variable with AJAX to PHP page
  • dataTable Headers Misaligned
  • Selected row not highlighted in jqgrid
  • CakePHP equivalent of html code
  • How to rewrite history in git?
  • Ruby on Rails: connect a function with the bootstrap botton
  • Edit with bootstrap modal and AngularJS
  • Manipulate FontAwesome with Javascript
  • Laravel image submit button
  • I want to get the edit dialog on click of a link..I have attached the code
  • How to delete a row in a table using jQuery?
  • Upgrading from netbeans 6.9 --> 6.9.1 on mac
  • do.call to build and execute data.table commands
  • Sass output style doesn't update when changed
  • UIVisualEffectView creates a grey box instead of blurring
  • css background transition in opera goes through black
  • Jquery-Bootgrid, Row is null on click
  • WPF: CanExecute is Always Disabled
  • Get attributes of existing SVG elements and bind as data with d3.js
  • Setting color in a row of a Jtable
  • Can't find cygwin setup.exe file?
  • UIButton Borders Function Only Gives Back White Borders
  • What is ./.local/share/Trash (Unix) [closed]
  • How to split circle in to the sectors in google maps?
  • How to modify the colors in the legend of a plot using a fill gradient?
  • OpenGL 3.3 on Mac OSX El Capitan with LWJGL
  • How to convert from System.Drawing.Color to Excel.ColorFormat in C#? Change comment color
  • How to show dropdown in excel using jrxml (jasper api)?
  • Cannot Parse HTML Data Using Android / JSOUP
  • SQL merge duplicate rows and join values that are different
  • Proper way to use connect-multiparty with express.js?
  • NSLayoutConstraint that would pin a view to the bottom edge of a superview
  • How to set the response of a form post action to a iframe source?
  • How get height of the a view with gone visibility and height defined as wrap_content in xml?
  • Getting Messege Twice Using IMvxMessenger
  • Android Google Maps API OnLocationChanged only called once
  • python draw pie shapes with colour filled
  • How to load view controller without button in storyboard?