jQuery jqGrid Show message when an edit row is complete

I am following this tutorial here http://www.trirand.com/blog/jqgrid/jqgrid.html in LiveDataManipulation->EditRow

My grid receive data from script a.php. After the user can modify this data by the jqGrid. jqGrid after the modification data will send data to script B.php that update my database and return a message of response like "all goes well".
I want that this response is alerted or showed to user somewhere on the page.
Reading the tutorial and here http://www.trirand.com/jqgridwiki/doku.php?id=wiki:form_editing I think that I've to use afterSubmit option, but I haven't understood how print on the edit panel the result.

I have written:

var gr = jQuery("#tabImprese").jqGrid('getGridParam','selrow');
if( gr != null ) jQuery("#tabImprese").jqGrid('editGridRow',gr,{
    closeAfterEdit : true,
    afterSubmit: function(response,postdata){ 
        else success = false;

        return [success,response.responseText] 

How can I do it? Thanks.



First of all the option closeAfterEdit:true follows to closing of the edit form after the successful server response. You should change the setting to the default value closeAfterEdit:false to be able to show anything.

Next I would recommend you to use navigator toolbar instead of creating a button after outside of the grid. In the case you can use

var grid = jQuery("#tabImprese");
grid.jqGrid('navGrid','#pager', {add:false,del:false,search:false}, prmEdit);

One more good option is to use ondblClickRow event handler

ondblClickRow: function(rowid) {

(see here) or both ways at the same time.

In any way you have to define the options of editGridRow method (the prmEdit). It's important to know that afterSubmit will be called only if the server response not contains error HTTP status code. So you should use errorTextFormat to decode the error server response. The afterSubmit event handler you can use to display status message.

In the demo I used only errorTextFormat to demonstrate both displaying of the status and error message:

enter image description here

The status message goes away in 3 seconds:

enter image description here

The corresponding demo you will find here.

In real example you will of cause place the code writing status message inside of afterSubmit event handler and the code which returns the error message inside of errorTextFormat.


Recent Questions

Top Questions

Home Tags Terms of Service Privacy Policy DMCA Contact Us

©2020 All rights reserved.