@model IEnumerable<SyncfusionMvcApplication4.Models.Game>
@section scripts {
<script src="@Url.Content("~/Scripts/jquery.validate.min.js")"></script>
}
<h2>Games</h2>
@(Html.EJ().Grid<SyncfusionMvcApplication4.Models.Game>("Editing")
.Datasource(ds => ds.Json((IEnumerable<object>)Model).BatchURL("/Games/Update").Adaptor(AdaptorType.RemoteSaveAdaptor))
.EditSettings(edit =>
{
edit.AllowAdding().AllowDeleting().AllowEditing().EditMode(EditMode.Batch).FormPosition(FormPosition.BottomLeft);
})
.ToolbarSettings(toolbar =>
{
toolbar.ShowToolbar().ToolbarItems(items =>
{
items.AddTool(ToolBarItems.Add);
items.AddTool(ToolBarItems.Edit);
items.AddTool(ToolBarItems.Delete);
items.AddTool(ToolBarItems.Update);
items.AddTool(ToolBarItems.Cancel);
});
})
.AllowPaging()
.Columns(col =>
{
col.Field("Id").HeaderText("Id").IsPrimaryKey(true).TextAlign(TextAlign.Right).Width(90).IsIdentity(true).Visible(false).Add();
col.Field("GameDescription").HeaderText("Game").TextAlign(TextAlign.Left).Width(90).ValidationRules(v => v.AddRule("required", true)).Add();
col.Field("GameDate").HeaderText("Date").Format("{0:dd/MM/yyyy HH:mm}").EditType(EditingType.DateTimePicker).TextAlign(TextAlign.Left).Width(90).ValidationRules(v => v.AddRule("required", true)).Add();
col.Field("GameTypeId").HeaderText("Game Type").ForeignKeyField("Id").ForeignKeyValue("GameTypeName").DataSource((IEnumerable<object>)ViewBag.gameTypes).Width(75).ValidationRules(v => v.AddRule("required", true)).Add();
})
)
The above is code I am using for a grid which works just fine in batch mode. However, if I add a new row and click save immediately validation does not fire and the empty model passes to my controller which obviously requires work in the background to handle the error. Ideally I'd like the validation methods to take care of this on the client side. Why wouldn't my validation rules be triggering here when save is pressed?
FYI, I have <add key="UnobtrusiveJavaScriptEnabled" value="false" /> in my web.config.