I managed to change the endpoint of kendoGrid.dataSource.transport.options.create.url and redirect it into a different endpoint
is there a way to change the e.response and e.type in this code? code bellow. I was talking about the parameter of the callback of requestEnd
requestEnd: function (e) {
var response = e.response;
var type = e.type;
console.log(e, 'I am event');
console.log("i triggered again and i am response", response);
console.log("i am type", type);
return 0;
if (type !== "read") {
toastr.options = {
positionClass: "toast-top-right"
};
if (type === 'update') {
if (!response.success) {
toastr.error(response.errorMessage, 'Account Update');
} else {
toastr.info('Acount detail successfully updated', 'Account Update');
}
} else if (type === 'create') {
if (!response.success) {
toastr.error(response.errorMessage, 'Message');
} else {
toastr.info('New Account successfully added', 'Message');
}
}
$('#grid').data('kendoGrid').dataSource.read();
$('#grid').data('kendoGrid').refresh();
}
},
I really appreciate your help! anyone that could help me should deserve a raise :)
CodePudding user response:
I would change approach to this problem. You can capture responses for each request based on type in complete
section. Console log response
and errorThrown
to see what do you get from server
transport: {
read: {
url: '',
type: 'GET',,
contentType: 'application/json',
complete: function(response, errorThrown) {
if (errorThrown === 'error') {
toastr.error(response.errorMessage, 'Account Read')
} else {
var responseData = response.responseJSON.accounts; //presumably array of accounts
toastr.info('Acounts fetched', 'Account Read');
}
}
},
update: {
url: '',
type: 'POST',
contentType: 'application/json',
complete: function (response, errorThrown) {
if (errorThrown === 'error') {
toastr.error(response.errorMessage, 'Account Update')
} else {
toastr.info('Acount detail successfully updated', 'Account Update');
}
}
}
}