This is a migrated thread and some comments may be shown as answers.

[Solved] Question about ClientEvent OnError for Grid

4 Answers 188 Views
Grid
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Adam Wan
Top achievements
Rank 1
Adam Wan asked on 13 Sep 2010, 03:50 PM
function onError(e)
{
e.preventDefault();
}

I can run this script, but preventDefault() doesn't work, it still shows default error message. Why?
Another question is about parameter e?

In server side, I throw an exception with some info I want to show in client.
How can I get this info in the cliend side.

[GridAction]
update()
{
throw new Exception("This message I want to show in the client side.")
}

function onError(e)
{
//how to get error message ("This message I want to show in the client side.")

e.preventDefault();
}

Can you tell me how to do it.

Thanks in advance.

4 Answers, 1 is accepted

Sort by
0
Peter
Top achievements
Rank 1
answered on 13 Sep 2010, 04:20 PM
Hi,

I think that you can get the error message like that:
function onError(e){
var errorText = e.textStatus
}

Also OnError is not cancellable. It is clearly shown the example description that OnError is not cancellable.

Regards,
Peter
0
Adam Wan
Top achievements
Rank 1
answered on 13 Sep 2010, 05:21 PM
You can cancel the OnError event by calling the preventDefault method of the event argument:
<script type="text/javascript">
function Grid_onError(e) {
    e.preventDefault();
}
</script>
Cancelling the OnError event will prevent the grid from showing a message box with error details.

Above text that I got from the chm help file. I'm not sure which one is correct indeed.

You know, I use ajax to save data, but sometimes it failed to save data for some reason.
I just want to get the failed information from server.
How to do use the ajax binding.

e.textStatus can't support my requirement.

Please give me any solution.

0
Peter
Top achievements
Rank 1
answered on 14 Sep 2010, 08:30 AM
Hi,

You are absolutely correct. You can prevent default action of Error event. My bad :)
Actually here what parameters are send to the event handler:
var prevented = this.trigger(element, eventName,
    {
        XMLHttpRequest: xhr,
        textStatus: status
    });

You can use textStatus or XMLHttpRequest. I do not believe that you can get more information from XMLHttpRequest object (which is natural Javascript object actually ) then any other place. So I will suggest you examine XMLHttpRequest object.

Regards,
Peter
0
Adam Wan
Top achievements
Rank 1
answered on 14 Sep 2010, 08:38 AM
Many thanks, Peter.

If we can prevent default error, how to do it?

My MSN:adamwan69@hotmail.com
Skype:adamwan69

Can you add me to talk.

Thanks
Tags
Grid
Asked by
Adam Wan
Top achievements
Rank 1
Answers by
Peter
Top achievements
Rank 1
Adam Wan
Top achievements
Rank 1
Share this question
or