Hi Carlos,
Thank you for contacting Syncfusion support.
We have prepared a sample with the Data Annotation and it can be downloaded from the following location.
We have prepared Order class which holds the data annotation properties of the required columns of Grid and its class name can be given as type of object for the Grid as shown below. We need to refer jquery.validate.min.js and jquery.validate.unobtrusive.min.js scripts for validation. So, please refer to these script files in your sample. Also refer to the below help document and code example.
<script src="Scripts/jquery.validate.min.js"></script>
<script src="Scripts/jquery.validate.unobtrusive.min.js"></script> |
@using SyncfusionMvcApplication90.Models
@(Html.EJ().Grid<Order>("FlatGrid")
.Datasource(ds => ds.URL("/Grid/DataSource").UpdateURL("/Grid/Update").InsertURL("/Grid/Insert").RemoveURL("/Grid/Delete").Adaptor(AdaptorType.UrlAdaptor))
..
.Columns(col =>
{
..
col.Field("CustomerID").HeaderText("Customer ID").Width(80).Add();
..
}))
Order.cs
namespace SyncfusionMvcApplication90.Models
{
public partial class Order
{
public int OrderID { get; set; }
[Required(ErrorMessage = "CustomerID is required")]
public string CustomerID { get; set; }
..
public virtual Employee Employee { get; set; }
}
} |
Regards,
Jayaprakash K.