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 error message for formedit modal dialog
22/09/2008
07:22
Avatar
Renso
PA
Member
Members
Forum Posts: 118
Member Since:
11/09/2008
sp_UserOfflineSmall Offline

I my asp.mvc app I am using jqGrid to add/edit account addresses by using the jqGrid modal dialog box. The problem is that I do not want to use the loaderror event as this means I have to throw an exception on my server for it to trickle up for two reasons, one that when performing server side validation on user input I do not want to throw an exception as it will write an entry into my DB error log, which is not right as I only want to write unhandled exception to it and not user input validation issues, second I do not want to reveal the server side error to my user in an alert and or new window. What I need is for the formerror ".modalwin.jqmWindow .modalcontent table.EditTable tr#FormError" table row to also work or be leveraged for errors not just in search but also for editing and adding ne records via modal dialog box.

I tried to poke around in the jqGrid code and although I have it working for searches still have to edit jqGrid for editing/adding records. What I am doing is adding a “Message property to the jsonReader that maps to an additional property in my returned json data string, which contains a list of user errors in an unnumbered list format, that I want to throw into the formError row. I know you are working on getting something like this into the next release but I don’t know when this will possibly be done and if it is a long way off is there a way for me to do it now; i.e. do you have some pointers for me on how/where in the code to look?

22/09/2008
08:49
Avatar
tony
Sofia, Bulgaria
Moderator
Members

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

Hello,

It is really difficult to me to undersyand what you mean. Sorry.

You can use afterSubmit event for this purpose.

This event accept arbitrary data from serever and depending on it

you can return true(succes) and false again with the message which

is displayed in the form error id.

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.

22/09/2008
13:16
Avatar
Renso
PA
Member
Members
Forum Posts: 118
Member Since:
11/09/2008
sp_UserOfflineSmall Offline

Hi Tony thanks for the speedy reply. I cannot use aftersubmit as I am using the modal dialog that performs an ajax call and not a form submit, unless I do not understand what events fire with the modal dialog but as far as I understand the modal dialog, not the inkline edit, only performs an ajax call and the aftersubmit will not fire, is that the correct assumption?

What I meant in my original post is that I have included an error message as part of my JSON return string from the server. I want to parse out the error from the JSON string (as you currently do for pages, rows, etc) and display it inside the modal dialog of the formedit. The return string looks like this after I click “submit” on the “Edit Record” modal dialog:

{"CurrentPage":1,"TotalPages":0,"TotalRecords":0,
“Message”:”\\The postal code is invalid”,”Addresses”
:null}

So inside the formedit modal dialog I want to be able tio display this
message.
22/09/2008
15:11
Avatar
tony
Sofia, Bulgaria
Moderator
Members

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

Hello,

Not sure if this is the case, but

loadComplete: function() {

// use userdata from jsonReader / get it and depending on the

// condition

if(something_from user_data == true){

ViewModal("#editmod"+your_grid_id); // ViewModal is separate func

$("#FormError > td","#editmod"+your_grid_id).html("The message

here").show();

}

}

Enjoy

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.

22/09/2008
16:21
Avatar
Renso
PA
Member
Members
Forum Posts: 118
Member Since:
11/09/2008
sp_UserOfflineSmall Offline

That looks good Tony, you are right I can do it outside of jqGrid but am hoping you folks would include a more "built-in" property and message area for the modal dialog for edits and inserts.

The big problem with this approach on modal dialog's edit/add record is that the "loadComplete" event only fires on initial load and not after every "submit" from the edit/add modal dialog box's ajax call, so which event fires after each one of these events? For example in the Live Data Manipulation NAVIGATOR example, when you click on "Edit selected row", when the server returns data via userdata and I get it via getUserData(), on what event do I need to attach it, as loadComplete doesn't fire after the ajax call?

22/09/2008
17:20
Avatar
tony
Sofia, Bulgaria
Moderator
Members

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

Which way do you submit data to the server?

Really I do not understand?

If you post data via formedit WHAT IS THE PROBLEM

to use afterSubmit when you add and edit Record?

When you post data this way there is server response

right? Then

.navGrid(pager,{…},

{ afterSubmit: function(serverresponse,data){

// catch here the response 

if( error form server) {

return[false,"Your message"]

} else {

return[true]

}

} // this is for add

 … continue for edit and del

…)

This way this message is displayed automatically in the

edit form

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.

23/09/2008
08:05
Avatar
Renso
PA
Member
Members
Forum Posts: 118
Member Since:
11/09/2008
sp_UserOfflineSmall Offline

Hi Tony, I had to laugh when I realized what had happened. I specified the "afterSubmit()" event as a event directly on the jqGrid instead of specifying it as part of the events for "navGrid()". It now works as you had excplained. Sorry for the confusion, my bad. Thank you for taking the time to help me.

23/09/2008
12:06
Avatar
Renso
PA
Member
Members
Forum Posts: 118
Member Since:
11/09/2008
sp_UserOfflineSmall Offline

Hi Tony, this may be more of a jQuery question but I am returing an un-numbered list from the server of all errors (see below) but for some reason although it renders my html tags perfectly it does not display it in html format:

JSON formatted ERRORS looks like:<ul><li>Zip code is in wrong format</li><li>Street address line 1 is invalid</li></ul>

code:

afterSubmit: function(response, postdata) {
var errors = eval('('+ response.responseText +')').Errors.Errors;
if (errors) {
        $('#FormError>td','#TblGrid_ListAccountAddresses').text(errors);         $('#FormError>td>ul','#TblGrid_ListAccountAddresses').css({'list-style-type': 'disc', 'list-style-position': 'outside'});
$('#FormError','#ListAccountAddresses').show();
return [false, errors];
}
else
           return [true];
}//end of afterSubmit's if-then-else

Also as you can see from above the css styling has also no affect. If I edit the html in Firebig by making any change to that HRML, suddenly the html tags take affect and it displays the list correctly. Any ideas of why it is doing this?

24/09/2008
03:48
Avatar
tony
Sofia, Bulgaria
Moderator
Members

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

Hello,

You are right in the code I use text function, wich display data

as text only and not as html. I will correct this.

Thank you

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:
78 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