Forum

November 2nd, 2014
A A A
Avatar

Lost password?
Advanced Search

— Forum Scope —




— Match —





— Forum Options —





Minimum search word length is 3 characters - maximum search word length is 84 characters

The forums are currently locked and only available for read only access
sp_Feed Topic RSS sp_TopicIcon
handling response from 'afterSubmit' method
18/02/2010
00:34
Avatar
mstone42
New Member
Members
Forum Posts: 2
Member Since:
17/02/2010
sp_UserOfflineSmall Offline

I'm having a problem with handling the server response from an edit event.  Ideally, what I'd like to have happen is that on a successful transaction, the edit form simply closes and the grid is updated; if an error occurs during the update, the edit form should stay open, and the error message appear on the form (e.g. bottominfo).  However, I'd settle for leaving the form open regardless of the result, and print the result message either way.  I've got the form working as far as updating the database, but I can't find where the 'afterSubmit' function is sending the result array.  None of the examples in the demo pack illustrate this feature, and I haven't been able to find anything helpful in the forums.

Here's my grid so far:

    $("#list").jqGrid({
        url:'data.php',
        datatype: "json",
        mtype: "POST",
        colNames:[...],
        colModel:[...],
        editurl:"data_edit.php"
    });
    $("#editdata").click(function(){
        var id = jQuery("#list").jqGrid('getGridParam','selrow');
        var options = {
            bottominfo: "",
            modal: true,reloadAfterSubmit:true, closeOnEscape:true,closeAfterEdit:false,
            afterSubmit: function(response,postdata){ return GetResponseData(response); }
        };
        if(id != null ) jQuery("#list").jqGrid('editGridRow',id,options);
        else alert("Please Select Row");
    });
    function GetResponseData (resp) {
        var json=resp.responseText;  //format is {errno:(int),errmsg:"",query:""}
        var result=eval("("+json+")");
        return [result.errno,result.error,""];
    }

I know that the value of the array returned from the 'afterSubmit' event needs to be the assigned to 'bottominfo' property, something along the lines of:

    var z = ???; // array sent from afterSubmit
    $('.bottominfo').text("ERROR [" + z.errno + "] " + z.errmsg);

but I can't fingure out where this needs to go.

Another problem I've just realized is that there is no 'bottominfo' property associated with the 'delGridRow' method.  I suppose I could overwrite the table row which has the 'delmsg' class, which takes us right back to the problem of accessing the 'afterSubmit' array.

HELP!!!

Thanks,
Mitch

20/02/2010
12:11
Avatar
tony
Sofia, Bulgaria
Moderator
Members

Moderators
Forum Posts: 7721
Member Since:
30/10/2007
sp_UserOfflineSmall Offline

Hello,

If you set closeAfterEdit to false (from your example) the dialog will not close after post. If you set it to true the will close if there is no error - in case that afterSubmit check this.

The first parameter in afterSubmit should be true and not number (int) as per your example.

The error information apper at top and not at bottom.

Regards

Tony

For professional UI suites for Java Script and PHP visit us at our commercial products site - guriddo.net - by the very same guys that created jqGrid.

Forum Timezone: Europe/Sofia

Most Users Ever Online: 715

Currently Online:
72 Guest(s)

Currently Browsing this Page:
1 Guest(s)

Top Posters:

OlegK: 1255

markw65: 179

kobruleht: 144

phicarre: 132

YamilBracho: 124

Renso: 118

Member Stats:

Guest Posters: 447

Members: 11373

Moderators: 2

Admins: 1

Forum Stats:

Groups: 1

Forums: 8

Topics: 10592

Posts: 31289

Newest Members:

, razia, Prankie, psky, praveen neelam, greg.valainis@pa-tech.com

Moderators: tony: 7721, Rumen[Trirand]: 81

Administrators: admin: 66

Comments are closed.
Privacy Policy   Terms and Conditions   Contact Information