EasyUI Forum

General Category => EasyUI for jQuery => Topic started by: James on September 29, 2019, 01:27:01 AM



Title: How to catch datagrid load error info?
Post by: James on September 29, 2019, 01:27:01 AM
When use datagrid,
if it returns {'code':1,'info':'Some error!'} instead json as expected,
How to handle this return data, and make a alert window?


Title: Re: How to catch datagrid load error info?
Post by: jarry on September 29, 2019, 07:03:48 PM
Custom the 'loadFilter' function to handle the specified message. Please try this code.
Code:
$('#dg').datagrid({
loadFilter: function(data){
var oldData = $(this).data('datagrid').data;
if (data.info){
setTimeout(function(){
alert(data.info)
},0)
return oldData
} else {
return data;
}
}
})