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

How to handle errors from OData Datasource in Grid?

2 Answers 187 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Adam
Top achievements
Rank 1
Adam asked on 07 Dec 2012, 06:10 AM
I have a question of the recommended way to handle errors from the Kendo Grid when using an OData data source.

I understand that using a custom data source, you can use the schema.errors property to define the property in the data source that contains errors.

Does OData have a corresponding concept?  If not - is there a recommended way to handle errors from OData data sources?

Also - what does the grid do with any errors it receives?  Log them using the kendo log API or something else?

thanks,
Adam

2 Answers, 1 is accepted

Sort by
0
Petur Subev
Telerik team
answered on 11 Dec 2012, 10:08 AM
Hello Adam,

Basically if exception is thrown on the server side when performing update you could override the HandleException like explain here:

http://blogs.msdn.com/b/writingdata_services/archive/2011/03/06/interesting-behavior-for-service-operation-exceptions.aspx

and override the Exception so you can have more detail information what exactly happened on the client side.

Of course on the client side you will need to handle the error event of the dataSource.

e.g.
c#
protected override void HandleException(HandleExceptionArgs args)
{
    args.Exception = new Exception("My custom exception");
    base.HandleException(args);
}

JavaScript:

error: function (e) {
    alert(JSON.parse(e.responseText).error.innererror.message);
 },


Kind Regards,
Petur Subev
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Adam
Top achievements
Rank 1
answered on 11 Dec 2012, 03:15 PM
Great, this is what I was looking for.  THanks.
Tags
Grid
Asked by
Adam
Top achievements
Rank 1
Answers by
Petur Subev
Telerik team
Adam
Top achievements
Rank 1
Share this question
or