2

Is there a way to show custom exception messages sent from the server in my jqGrid???? One of my function does a throws clause and throws some exception. I need to disoplay the error message relative to this thrown exception... Is there a way to do that in jqGrid???

apoorvabade
  • 575
  • 2
  • 11
  • 25

1 Answers1

4

You don't spectify in what jqGrid operation the exception could be throwen. There are different event handler which you can use to receive the text of the error message from the exception and decode it.

For example loadError(xhr,st,err) can be used to display the error messege which appears on the server during the loading of the jqGrid. I mean here the errors returned by the server on the ajax requests.

Additionally errorTextFormat(data) can be used to decode errors come up from the server during the ajax requests of the form editing. or errorfunc(rowid,res,stat) for the inline editing and errorCell(serverresponse,status) for cell editing.

So you can use the corresponding event handler functions in different places to decode the text of the exception message.

Oleg
  • 220,925
  • 34
  • 403
  • 798
  • Any recommendations on what codes we should be testing for as part of the loadError function? How would I ignore an error based on the XMLHttpRequest not being able to finish with a user moving away to another page before the request has finished? – Mark Apr 15 '13 at 18:04
  • @Mark: Sorry, but I don't understand your question about `loadError`. To cancel previous pending Ajax request you can call `.abort()` of `XMLHttpRequest` of *the previous request* (see [the answer](http://stackoverflow.com/a/4017022/315935)). – Oleg Apr 15 '13 at 18:31
  • The loadError function is triggered when a user leaves the page, is there a way to ignore this but still handle other exceptions to the jqGrid request? – Mark Apr 15 '13 at 18:48
  • @Mark: Sorry, but the callback `loadError` will be called if the server returns response with an HTTP error code or if the *local* error take place. For example if one abort pending request the `loadError` will be also called (see [the answer](http://stackoverflow.com/a/9964979/315935)). I don't know the reason why the `loadError` will be called if the user leaves the page. Probably you execute Ajax `abort` explicitly? Do you have live demo which demonstrate the problem? – Oleg Apr 15 '13 at 18:59
  • No I don't call the abort myself, should I generate a new question so I can put up the code I use and I can at least reward you for your time via an answer? I do have this working in production but it is inside a registration wall – Mark Apr 15 '13 at 19:07
  • @Mark: It's probably the best way. It would be nice if you could prepare some demo which reproduces the problem. Only in the case one can be sure that the code which you post really contains the origin of the problem. If it's difficult, you can first describe the problem more detailed in your question and post some parts of code which you find the most important. – Oleg Apr 15 '13 at 19:13
  • I'll do so and do my best to get a demo up tomorrow and reply to this post. Thanks for your help. – Mark Apr 15 '13 at 19:19