I'm facing the same situation. The aspnet-core documentation is an missing the data-annotation page from aspnetmvc: https://help.syncfusion.com/aspnetmvc/grid/data-annotation.
[View] @using Syncfusion.JavaScript.Models @model IEnumerable<Orders> @{ Html.EJ().Grid<Orders>("FlatGrid").Datasource(Model).AllowPaging().Render(); } [Model] public class Orders { . . . [Display(Name = "Order ID")] public long OrderID { get; set; } public string CustomerID { get; set; } [Display(Name = "Emp ID")] public int EmployeeID { get; set; } [Display(Name = "Freight")] public double Freight { get; set; } public DateTime OrderDate { get; set; } [Display(Name = "City")] public string ShipCity { get; set; } [Display(Name = "Country")] public string ShipCountry { get; set; } } [Controller] public IActionResult Index() { List<Orders> data = GetData(); return View(data); } |
Thanks for the reply. I am using ViewModels that inherit from Models. It looks like the annotations defined in the Model are available in the View but not the ones from the ViewModel.
I've attached a project that illustrates this. I created a new project using the latest asp.net core 2.0 templates in VS2017 since I could not actually run your example. My system attempted to upgrade it and it does not run.
In the test project, the property "Enabled" is defined in the ViewModel and its annotation is ignored. The other properties are defined in the Model and are displayed.
Regards
Jim
{
Html.EJ().Grid<OrderViewModel>("FlatGrid")
. . .
} |