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

How to add global error handler

4 Answers 161 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Bhupendra
Top achievements
Rank 1
Bhupendra asked on 12 May 2013, 11:20 AM
Hi,

 I want to add a global error handler that gets called when any AJAX call made by a Kendo control fails. So I have a kendo window opening as a popup that has a grid that has regular methods like read, update. It has url's pointing to WCF services. Now I want to catch errors in my global handler that may come from my WCF calls. I tried using $.ajaxerror but its not getting called for kendo calls, for others its working. I also tried the following code but it didnt work:
kendo.data.DataSource.prototype.options.error = function (e) {
            //your logic
            alert('kendo error');
        };

So can you please point to me how to add global error handler for my ajax calls from kendo controls.
Thanks in advance.

4 Answers, 1 is accepted

Sort by
0
Petur Subev
Telerik team
answered on 14 May 2013, 01:12 PM
Hello Bhupendra,

When there is an error while executing Ajax requests the dataSource will trigger its error event.

http://docs.kendoui.com/api/framework/datasource#events-error

However global error handler is not supported. You can try to set a handler to that event dynamically to all your Grids like this:

$(function(){ //after initializing all the Grids
    $('.k-grid').each(function(){
         $(this).data().kendoGrid.dataSource.bind('error', yourHandler);
    })
})


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
Blair
Top achievements
Rank 1
answered on 17 Jun 2013, 07:14 AM
Hi,
I am working on my project which need Kendo DataViz including Gauge, Datagrid, PieChart and Bar Chart. I have tested Datagrid error event handler, but Gauge doesn't work. Would you please advice me if I should use global error handler or handle it individually? Also can you please provide some sample code for gauge error handler?

Many thanks,
George
0
Petur Subev
Telerik team
answered on 19 Jun 2013, 07:27 AM
Hello George,

The Gauge does not provide you with error handler neither it has dataSource:

http://docs.kendoui.com/api/dataviz/radialgauge


Regarding the dataSource of the charts - you can use the same approach to attach error handler. The difference is that the class name of the chart widget is "k-chart" and the client object is called kendoChart



Regards,
Petur Subev
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Jon
Top achievements
Rank 1
answered on 26 Apr 2019, 06:03 PM

Your syntax is wrong.  should be

$(this).data('kendoGrid').dataSource.bind('error', yourHandler);

 

Tags
General Discussions
Asked by
Bhupendra
Top achievements
Rank 1
Answers by
Petur Subev
Telerik team
Blair
Top achievements
Rank 1
Jon
Top achievements
Rank 1
Share this question
or