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

How to Prevent refresh When DB failed

1 Answer 185 Views
Grid
This is a migrated thread and some comments may be shown as answers.
zhang
Top achievements
Rank 1
zhang asked on 13 Apr 2018, 07:58 AM

Here is my example code(Delete):

destroy: {
type: 'post',
url: base_url + "delete",
dataType: "json",
contentType: 'application/json; charset=utf-8',

complete: function (jqXhr, data) {

if (jqXhr.responseJSON.success) {
}
else {
}

alert(jqXhr.responseJSON.msg)

console.log(jqXhr, data)

return false;

}

My response json : {"id":null,"success":false,"msg":"操作失败!","response":null}

 

PLS help.

 

1 Answer, 1 is accepted

Sort by
0
Konstantin Dikov
Telerik team
answered on 17 Apr 2018, 04:51 AM
Hello Zhang,

The correct way for handling request errors is within the "error" event of the DataSource:
As for preventing the refresh of the Grid, preventing the dataBinding event should do the trick:
function error(args) {       
        if (args.errors) {
            var grid = $("#grid").data("kendoGrid");
            grid.one("dataBinding", function (e) {  
                e.preventDefault();   // cancel grid rebind if error occurs                            
             
            });
        }
    }

Hope this helps.


Regards,
Konstantin Dikov
Progress Telerik
Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Tags
Grid
Asked by
zhang
Top achievements
Rank 1
Answers by
Konstantin Dikov
Telerik team
Share this question
or