Doest Header text uses Display name attribute in view model ?

Hello

In JS1 the grid automatically used a Name value from the Display attribute in the databound viewmodel for a column header. It doesn't seem to work in JS2.
For example, with grid item viewmodel

        public class GridItemViewModel
        {
            public string Id { get; set; }
            [Display(Name = "Surname")]
            public string LastName { get; set; }
...

In the JS1, the grid

.Grid("grid").Columns(col => { col.Field("LastName").Add() ...etc...}

would automatically show Surname as a header text in the grid. Is there a similar functionality in JS2 Grid?

Thanks,





8 Replies

VA Venkatesh Ayothi Raman Syncfusion Team September 25, 2018 09:37 AM UTC

Hi Tomislav, 

Thanks for contacting Syncfusion support. 

We have already considered “Provide Data Annotation support for Grid” as a feature. This implementation will be available on any of upcoming release. 


Regards, 
Venkatesh Ayothiraman. 



TT Tomislav Tustonic September 25, 2018 10:00 PM UTC

Hello
Thanks for the reply.
Do you know when to expect the next release ?

Tom


VA Venkatesh Ayothi Raman Syncfusion Team September 26, 2018 06:35 AM UTC

Hi David, 
 
Thanks for the update. 
 
This “Provide Data Annotation support for Grid” feature implementation will be available on upcoming Volume 4, 2018 release. Until we appreciate your patience. 
 
 
Regards,
Venkatesh Ayothiraman.
 



PS Pavithra Subramaniyam Syncfusion Team April 25, 2019 11:53 AM UTC

Hi Tomislav,  
 
Thanks for your patience.  
 
We would like to let you know that We have added feature support “Need to provide Data Annotation support for server side validation in Grid” and included in the Volume 4, 2018 release. Please upgrade to our latest version to use this feature. 
 
Regards, 
Pavithra S. 



TT Tomislav Tustonic April 25, 2019 12:57 PM UTC

Thanks!
I'll try it soon, when I push the next version of my software

Tom


PS Pavithra Subramaniyam Syncfusion Team April 26, 2019 04:13 AM UTC

Hi Tomislav,  

Thanks for your update. 

Please contact us if you need any further assistance. As always, we will be happy to assist you.  

Regards,  
Pavithra S. 



PE Petr May 2, 2020 10:58 PM UTC

Hello,
does this feature require some addition annotation on the class or attribute set up on the grid? 
I can't see any example in documentation and it's not working just out of box.

Thanks,
P.


BS Balaji Sekar Syncfusion Team May 4, 2020 06:13 AM UTC

 
 We have provided data annotation support for Grid so you can able do the validation in server side. Please refer the below code example and sample for more information. 
 
[index.cshtml] 
 
<div> 
    @(Html.EJS().Grid<OrdersDetails>("Grid") 
.EditSettings(e => { e.AllowAdding(true).AllowEditing(true).AllowDeleting(true); }).Columns(col => 
{ 
    col.Field("OrderID").HeaderText("Order ID").IsPrimaryKey(true).Width("30%").Add();     
    col.Field("CustomerID").HeaderText("CustomerID").Width("70").Add(); 
    . . . . 
    col.Field("ShipCity").HeaderText("Ship City").Width("70").Add(); 
    col.Field("ShipCountry").HeaderText("Ship Country").Width("70").Add(); 
 
}).AllowPaging().Toolbar(new List<string>() { "Add", "Edit", "Delete", "Update", "Cancel" }).Render()) 
         
</div 
 
[HomeController] 
 
public static List<OrdersDetails> GetAllRecords() 
        { 
            List<OrdersDetails> order = new List<OrdersDetails>(); 
             .   .   .   
 
        [Display(Name ="OrderID")] 
        [Key] 
        public int? OrderID { get; set; } 
 
        [Display(Name = "CustomerID")] 
        [MinLength(3, ErrorMessage = "Need atleast 3 characters")] 
        [MaxLength(10, ErrorMessage = "Characters exceed")]         
        public string CustomerID { get; set; } 
        [Range(2, 9)] 
        public int? EmployeeID { get; set; } 
        [Editable(false)] 
        [DisplayFormat(DataFormatString ="C2")] 
        public double? Freight { get; set; } 
        [Required (ErrorMessage ="Ship City is required.")] 
        public string ShipCity { get; set; } 
        public bool Verified { get; set; } 
        public DateTime OrderDate { get; set; }         
        public string ShipName { get; set; } 
        [Display(Name = "ShipCountry")] 
        [MinLength(3, ErrorMessage = "Need atleast 3 characters")] 
        [MaxLength(10, ErrorMessage = "Characters exceed")] 
        public string ShipCountry { get; set; } 
        public DateTime ShippedDate { get; set; } 
        public string ShipAddress { get; set; } 
    } 
 
 
 
Note: We have provided data annotation support for predefined validation only. 
 
If you want to use custom validation then we suggest you to use client side custom validation option to achieve your requirement. Please refer the below help documentation for more information  
 
 
Regards, 
Balaji Sekar 


Loader.
Up arrow icon