Grid - Auto generated columns


About this example


This example shows how DJME Grid can infer its columns based on the properties of the data item it is bound to. A columns is created for every public property of simple type (integer, string, date, enum and boolean). Column titles are inferred from the property name using pascal-case splitting - for example if the property name is CustomerID the inferred column title will be "Customer ID".

The Grid supports DataAnnotation features that you can set the column title in your data model.


using System.ComponentModel.DataAnnotations;

[MetadataType(typeof(CustomerMeta))]
public partial class Customer
{
   public class CustomerMeta
   {
       [Display(Name = "Customer code")]
       public string CustomerID { get; set; }
   }
}



<%
    Ajax.Dna().Grid()
       .Width(650)
       .Height(500)
       .AutoGenerateColumns(true)
       .ShowScrollBar(true)
       .ClientBind(Url.Action("ClientBinding", "Grid"))
       .Pagable(1, 20)
       .Render(); 
%>