EasyUI Forum
March 28, 2024, 03:09:25 PM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News:
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: Datagrid error handling  (Read 3552 times)
sectioni
Jr. Member
**
Posts: 67


View Profile
« 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..
« Last Edit: April 18, 2018, 06:30:54 AM by sectioni » Logged
stworthy
Administrator
Hero Member
*****
Posts: 3581


View Profile Email
« Reply #1 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);
}
});
}
});
Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines Valid XHTML 1.0! Valid CSS!