Forum
19:37
02/02/2009
Hi, I would like to perform server side validation that returns a list of errors, when a user has edited a row in the grid, before saving to the database.
On error I would like to stop the cancel the update, display the row, and the error message.
With the current functions I can't seem to do this.
afterSubmit: this doesn't allow me to return data from the server
beforeSubmit: if I do my own $.post request I can get my json data back but cannot return true/false.
02:42
Moderators
30/10/2007
Hello,
It is possible and I use this technique in all my projects.
afterSubmit : function (data, postdata) {
// data is the data returned from your server
// postdata is the array posted to the server
// this event should return array indicating if the post is ok
// Suppose you return text from server something like
// error: The post has error for error; and ok:data is ok if ok
// then
result = data.responseText.split(":");
if (result[0] = "error" ) {
return [false,result[1],""];
} else {
return [true,"",""];
}
Hope this help
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.
10:46
19/02/2009
Hi Tony.
As a lot people says, you rock. 😛
I thank your post about this. I was looking for a way of doing it.
What I would like is a way to make this the default behavior. Lets say, If anything goes ok, you could return the data as currently we do, and if an error ocurrs, return the string "error:error message". The jqGrid could provide an onError handler. For example:
onError: function(errorMessge) {
alert(errorMessage);
}
This way we could provide an easy way of error handling.
What do you say?
Most Users Ever Online: 715
Currently Online:
49 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