Yes, we have DisplayFormatAttribute support to apply formatting to the data displayed in the Grid. Please find the following code example, screenshot and sample as below,
@(Html.EJ().Grid<MVCSampleBrowser.Models.EditableOrder>("FlatGrid") .Datasource((IEnumerable<MVCSampleBrowser.Models.EditableOrder>)ViewBag.datasource) .AllowPaging() /*Paging Enabled*/ .EditSettings(edit => { edit.AllowEditing().AllowAdding().AllowDeleting(); }) .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); items.AddTool(ToolBarItems.Search); }); }) .Columns(col => { col.Field("OrderID").HeaderText("Order ID").IsPrimaryKey(true).TextAlign(TextAlign.Right).Width(75).Add(); col.Field("CustomerID").HeaderText("Customer ID").Width(80).Add(); col.Field("EmployeeID").HeaderText("Employee ID").TextAlign(TextAlign.Right).EditType(EditingType.Dropdown).Width(75).Add(); col.Field("Freight").HeaderText("Freight").TextAlign(TextAlign.Right).Width(75).Format("{0:C}").Add(); col.Field("OrderDate").HeaderText("Order Date").TextAlign(TextAlign.Right).Width(80).Add(); col.Field("ShipCity").HeaderText("Ship City").Width(110).Add(); }) public class EditableOrder { [Range(0, int.MaxValue, ErrorMessage = "OrderID must be greater than 0.")] public int OrderID { get; set; }
[StringLength(5, ErrorMessage = "CustomerID must be 5 characters.")] public string CustomerID { get; set; }
[Range(1, 9, ErrorMessage = "EmployeeID must be between 0 and 9.")] public int? EmployeeID { get; set; }
[DisplayFormat(DataFormatString = "{0:dd/MM/yyyy}")] public DateTime? OrderDate { get; set; } |
<style> .e-grid .e-gridheader { border-bottom-width: 1px !important; } |