function actionFailure(e){
showToast("An error has occurred","danger");
grid.refresh();
console.log(JSON.stringify(e));
$(".e-dlg-container.e-dlg-center-center").remove();
}
|
public IActionResult Insert([FromBody]CRUDModel<Orders> value)
{
if (value != null)
{
order.Insert(0, value.Value);
return Json(value.Value);
}
else {
throw new Exception("Insert required value");
}
} |
|
actionFailure: function (e) {
. . . .
var errorMsg = e.error[0].error.responseText.split("Exception:")[1].split("</div>")[0];
alert(errorMsg); // error message sent from server side
console.log(JSON.stringify(e));
. . .
} |
|
actionFailure: function (e) {
. . . .
setTimeout(function () {
grid.closeEdit() // you can close dialogObj
}, 100);
} |
|
public IActionResult Insert([FromBody]CRUDModel<Orders> value)
{
try
{
{
. . . . . . .
. . . . . . .
}
}
catch (Exception e)
{
// you can difereniate corresponding to message.
if (e.Message == "Object reference not set to an instance of an object.") { // we can compare with required status code (ex: 409) error message and decide exception message.
throw new Exception(e.Message); // throw the exception and you can get the error message in “ActionFailue” event
}
else
{
throw new Exception("Custom exception"); // // throw the custom exception and you can get the error message in “ActionFailue” event
}
}
} |
$validator = $this->validatePort(
request()->input('value.name'),
request()->input('value.number'),
request()->input('value.description'),
request()->input('value.location')
);
if($validator->fails()){
return response()->json($validator->getMessageBag()->getMessages(),409);
}
var dataManager = new ej.data.DataManager({
url: 'HOSTNAME/api/ports',
crudUrl: 'HOSTNAME/api/portsCrud',
adaptor: new ej.data.UrlAdaptor(),
crossDomain: true,
headers: [{"Authorization": "Bearer *******"}]
});
var grid = new ej.grids.Grid({
dataSource:dataManager,
actionFailure: actionFailure,.......
function actionFailure(e){
showToast("An error has occurred","danger");
grid.refresh();
console.log(JSON.stringify(e));
grid.closeEdit();
}
|
|