Hi,
I spent all the day to read your forum message to find a solution to my problem.
It seems to be simple, i want the controler to send an error message if crud operation fail.
I tried all the methods you already answered to other people who had the same problem, but it's not working for me, maybe because i'm using ASP.NET Core and not MVC ?
Here is my view :
<body>
<ej-grid id="FlatGrid" allow-paging="true" action-Failure="actionFailure" allow-filtering="true" allow-sorting="true" load="onLoad">
<e-page-settings page-size="4"></e-page-settings>
<e-filter-settings filter-type="Menu" />
<e-edit-settings allow-adding="true" allow-editing="true" allow-deleting="true" edit-mode="Normal" show-confirm-dialog="true" show-delete-confirm-dialog="true"></e-edit-settings>
<e-toolbar-settings show-toolbar="true" toolbar-items='@new List<string> {"add","edit","delete","update","cancel", "search" }' />
<e-datamanager json="(IEnumerable<object>)ViewBag.datasource" update-url="/Admin/UsersListCellEditUpdate" insert-url="/Admin/UsersListCellEditInsert" remove-url="/Admin/UsersListCellEditDelete" adaptor="remoteSaveAdaptor" />
<e-columns>
<e-column field="strTitre" header-text=@GetMsg("LIBID_USERS_TITRE") text-align="Left" width="30" edit-type="DropdownEdit" validation-rules='new Dictionary<string, object>() { { "required",true}, { "minlength",3}, { "maxlength",20} }'></e-column>
<e-column field="strPrenom" header-text=@GetMsg("LIBID_USERS_PRENOM") width="80" validation-rules='new Dictionary<string, object>() { { "required",true}, { "minlength",3} }'></e-column>
<e-column field="strNom" header-text=@GetMsg("LIBID_USERS_NOM") text-align="Left" width="75" validation-rules='new Dictionary<string, object>() { { "required",true}, { "minlength",3} }'></e-column>
<e-column field="strLogin" header-text=@GetMsg("LIBID_USERS_LOGIN") is-primary-key="true" text-align="Right" format="{0:C2}" width="75" validation-rules='new Dictionary<string, object>() { { "required",true}, { "email",true} }'></e-column>
</e-columns>
</ej-grid>
<script type="text/javascript">
function actionFailure(args) {
var popupObj = $("#FlatGrid").data("ejWaitingPopup");
popupObj.hide();
this.cancelEdit();
var str = "";
str = $(args.error.responseText).find('i').text();
alert(str);
alert(args.error.error.responseText);
alert(args.error.statusText);
alert('@(ViewData["strLastErrorMessage"])');
}
</script>
</body>
and here is my controler code :
public ActionResult UsersListCellEditInsert([FromBody]CRUDModel<FFWcfServerReference.CUsers> value)
{
ViewBag.strLastErrorMessage = "TEST";
ViewData["strLastErrorMessage"] = "TEST";
throw new Exception("TEST");
//Insert record in database
return Json(value.Value);
}
As you see, it looks like the same samples you've already show us.
The problem is that the alert messages are empty, or undifined, or internal server error when i tried all your samples.
And the viewbag is also empty, because i think that the page is not reloaded.
Can you show me please with a sample but for ASP.NET MVC CORE.
Thx by advance,
Fred (from France).