Hi, I am using the grid control in mvc with URLAdaptor, and I would like to know how to inform to the client side if an error occurred on the server side.
@(Html.EJ().Grid<object>("Test")
.Datasource(ds=>ds.URL(Url.Action("Data", "GridTest1", null, Request.Url.Scheme))
.InsertURL(Url.Action("Create", "GridTest1", null, Request.Url.Scheme))
.UpdateURL(Url.Action("Update", "GridTest1", null, Request.Url.Scheme))
.RemoveURL(Url.Action("Delete", "GridTest1", null, Request.Url.Scheme))
.Adaptor(AdaptorType.UrlAdaptor))
.EditSettings(edit => { edit.AllowAdding().AllowDeleting().AllowEditing().RowPosition(RowPosition.Bottom).EditMode(EditMode.ExternalForm); })
.Locale("es-ES")
.ToolbarSettings(toolbar =>
{
toolbar.ShowToolbar().ToolbarItems(item =>
{
item.AddTool(ToolBarItems.Add);
item.AddTool(ToolBarItems.Cancel);
item.AddTool(ToolBarItems.Delete);
item.AddTool(ToolBarItems.Edit);
item.AddTool(ToolBarItems.Update);
item.AddTool(ToolBarItems.ExcelExport);
item.AddTool(ToolBarItems.PdfExport);
item.AddTool(ToolBarItems.WordExport);
});
})
.AllowPaging()
.AllowReordering()
.IsResponsive()
.PageSettings(p => { p.PageSize(10); })
.AllowResizeToFit()
.AllowSorting()
.Columns(col =>
{
col.Field("MarcaId").HeaderText("ID").IsIdentity(true).IsPrimaryKey(true).Add();
col.Field("Marca").ValidationRules(v => v.AddRule("required", true).AddRule("messages", "{required:'Campo obligatorio'}")).Add();
col.Field("FechaAlta").AllowEditing(false).Add();
col.Field("FechaActividad").AllowEditing(false).Add();
col.Field("Status").HeaderText("Estatus").AllowEditing(false).Add();
})
.ClientSideEvents(e=> { e.ActionComplete("complete").ActionBegin("begin").EndEdit("endEdit").EndAdd("endAdd").ActionFailure("fail"); })
)
<script type="text/javascript">
function begin(args) {
if (args.requestType == "save") {
this.element.ejWaitingPopup("show");
}
}
function endEdit(args) {
this.element.ejWaitingPopup("hide");
}
function endAdd(args) {
this.element.ejWaitingPopup("hide");
}
function complete(args) {
console.log(args);
if (args.requestType == "cancel")
this.element.ejWaitingPopup("hide");
if (args.requestType == "save")
this.refreshContent();
}
function fail(args) {
console.log(args);
this.cancelEdit();
alert("Servicio no disponible");
}
</script>
first of all, Thanks.