EasyUI Forum

General Category => EasyUI for jQuery => Topic started by: sectioni on April 18, 2018, 05:59:09 AM



Title: Datagrid error handling
Post by: sectioni on April 18, 2018, 05:59:09 AM
Hello,

I have the following code:

Code:
$.ajaxSetup({
            complete: function (jqXHR, textStatus) {
                  // some code
            }
            , error: function (jqXHR, textStatus, errorThrown) {                                
                  // some error handling code                                    
            }
});

Is it possible to make the datagrid inherit that in addition to anything defined in OnLoadSuccess and OnLoadError?

By the way, the documentation says that the OnLoadError event isn't getting any parameters, but I checked and you're passing all 3 ajax error parameters to it..


Title: Re: Datagrid error handling
Post by: stworthy on April 20, 2018, 07:53:18 PM
You can override the 'loader' function and attach any features you want.
Code:
$.extend($.fn.datagrid.defaults, {
loader: function(param, success, error){
var opts = $(this).datagrid('options');
if (!opts.url) return false;
$.ajax({
type: opts.method,
url: opts.url,
data: param,
dataType: 'json',
success: function(data){
success(data);
},
error: function(){
error.apply(this, arguments);
}
});
}
});