|
[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; }
}
|