Forum


10:10

01/10/2009

I am new to jqgrid and I'm trying to get cell editing against a remote server working.
To me, it is not clear from the documentation or examples what the server should return in response to cell edit ajax requests. I can submit and perform a database update okay, but if there is a database error, what ever I return from the server, the grid updates. The only way I have found to display an error is to set the HTTP response code to 400 or 500 range, but can return no useful error message.
How do I return a meaningful server error and display it?
Using php & JSON the best I can work out from the documentation is something like this, is this correct?
echo json_encode(array(false, 'Update Failed'));
If so, how do I catch and display the error and prevent the grid from updating? Otherwise, what am I doing wrong.
Thanks, dj
11:07

12/08/2009

Here is how I take care of this.
afterSubmitCell: function (serverresponse, rowid, cellname, value, iRow, iCol) {
var mymess = serverresponse.responseText;
var retbool = true;
if (mymess != '1') { retbool = false; }
var myret = [retbool,mymess];
return myret;
},
I make sure that my server update routines return a '1' if all goes well, otherwise they return an error message that explains what the problem is. Then the grid will put up a dialog error with the returned message and nothing is changed in the cell.
Most Users Ever Online: 715
Currently Online:
67 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.comModerators: tony: 7721, Rumen[Trirand]: 81
Administrators: admin: 66