@(Html.EJ().Grid<object>("Grid")
.Datasource((IEnumerable<object>)ViewBag.datasource)
.AllowPaging()
.Columns(col =>
{
col.Field("OrderID").HeaderText("OrderID").TextAlign(TextAlign.Right).Width(90).Add();
col.Field("EmployeeID").HeaderText("Employee ID").TextAlign(TextAlign.Right).Width(90).Add();
col.Field("CustomerID").HeaderText("Customer ID").Width(100).Add();
col.Field("Freight").HeaderText("Freight").Format("{0:c2}").TextAlign(TextAlign.Right).Width(80).Add();
})
)
[controller]
public ActionResult Index(){
var Data = GetData();
ViewBag.dataSource = Data;
return View();
}
public static List<Details> GetData()
{
List<Details> jsons = new List<Details>();
int code = 1000;
for (int i = 1; i <= code; i++ ){
jsons.Add(new Details(){ OrderID = code +i, EmployeeID =i, CustomerID= "ALAKI", Freight = code * 0.23});
jsons.Add(new Details(){ OrderID = code +i+1, EmployeeID =i, CustomerID= "VINET", Freight = code * 0.56});
jsons.Add(new Details() { OrderID = code +i+2 , EmployeeID = i, CustomerID = "TOMSP", Freight = code * 0.11 });
jsons.Add(new Details() { OrderID = code + i+3, EmployeeID = i, CustomerID = "VICTE", Freight = code * 0.44 });
i = i+4 ;
}
return jsons;
}
public class Details {
public int OrderID { get; set; }
public int EmployeeID { get; set; }
public string CustomerID { get; set; }
public double Freight { get; set; }
}
}
|