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
Server Side Form Validation
03/02/2009
19:37
Avatar
melissa
New Member
Members
Forum Posts: 2
Member Since:
02/02/2009
sp_UserOfflineSmall Offline

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.

05/02/2009
02:42
Avatar
tony
Sofia, Bulgaria
Moderator
Members

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

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.

19/02/2009
10:46
Avatar
LimoWanKenobi
Member
Members
Forum Posts: 4
Member Since:
19/02/2009
sp_UserOfflineSmall Offline

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?

19/02/2009
12:02
Avatar
LimoWanKenobi
Member
Members
Forum Posts: 4
Member Since:
19/02/2009
sp_UserOfflineSmall Offline

I just realized that the afterSubmit event is usable only when editing the data.

I would like a way to handle the errors when loading the data too.

Right now I haven't found a clean solution. Do you have one? 😀

Any way, I'll keep looking.

Thanx!

19/02/2009
12:24
Avatar
LimoWanKenobi
Member
Members
Forum Posts: 4
Member Since:
19/02/2009
sp_UserOfflineSmall Offline

what a shame... my bad... I just realized that I can do it with loadError.

sorry

Forum Timezone: Europe/Sofia

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.com

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

Administrators: admin: 66

Comments are closed.
Privacy Policy   Terms and Conditions   Contact Information