or
public ActionResult Index(){ return View();}public static IEnumerable<Models.Customer> GetCustomers(){ var db = new Data.SomeDataContext(); var query = ... return query;}public static IEnumerable<Models.Orders> GetOrders(){ var db = new Data.SomeDataContext(); var query = ... return query;}public ActionResult CustomerOrder_Read([DataSourceRequest] DataSourceRequest request){ var query = from o in GetOrders() join c in GetCustomers() on o.CustomerAccountNumber equals c.AccountNumber select new CustomerOrder { Order = o, Customer = c }; return Json(query.ToDataSourceResult(request));}
<div> @(Html.Kendo().Grid<Apex.Models.CustomerOrder>() .Name("Grid") .Columns(col => { col.Bound(p => p.Order.OrderId); col.Bound(p => p.Order.Date); col.Bound(p => p.Order.Status); col.Bound(p => p.Customer.Name); col.Bound(p => p.Customer.Mobile); }) .DataSource(data => data .Ajax() .PageSize(10) .Read(read => read.Action("ServiceOrder_Read", "Home")) ) .Sortable() .Pageable() )</div>public class CustomerOrder{ public Customer Customer { get; set; } public Order Order { get; set; }}public class Customer{ public string AccountNumber { get; set; } public string Name { get; set; } public string Mobile { get; set; } public DateTime CreatedDate { get; set; } public DateTime ModifiedDate { get; set; }}public class Order{ public string Status { get; set; } public string OrderId { get; set; } public DateTime Date { get; set; }}Order Date Status Name Mobile
00-01 /Date(1364670000000)/ Open Adam 111-111-1111
00-02 /Date(1364670000000)/ Closed Eve 222-222-2222
00-03 /Date(1364670000000)/ Open Buddha 333-333-3333
public static class HtmlHelperExtensions { public static GridBuilder<T> SavitarCRUDGrid<T>(this HtmlHelper helper, string name) where T : class, IEntity { string entityType = typeof(T).ToString(); int index = entityType.LastIndexOf('.'); entityType = entityType.Substring(index + 1, entityType.Length - (index + 1)); return helper.Kendo().Grid<T>() .Name(name) .Groupable() .Pageable() .Sortable() .Scrollable() .Filterable() .Pageable() .Selectable(e => e.Mode(GridSelectionMode.Single)) .ToolBar(toolbar => toolbar.Create()) .Columns(columns => { columns.Bound(p => p.CreatedOn).Width(100).Format("{0:dd/MM/yyyy}"); columns.Command(command => { command.Edit(); command.Destroy(); }).Width(170); }) .Editable(editor => editor .Mode(GridEditMode.PopUp) .Window(window => window .Name("EditorWindow") .Title("Smartrail Editor") .Visible(false) .Modal(true) .Width(475) .Render() ) .TemplateName(entityType + "Editor") ) .DataSource(dataSource => dataSource .Ajax() .PageSize(20) .Model(model => model.Id(p => p.ObjectId)) .Events(events => events.Error("onError")) .Create(x => x.Action("Editor_Create", entityType)) .Read(x => x.Action("Editor_Read", entityType)) .Update(x => x.Action("Editor_Update", entityType)) .Destroy(x => x.Action("Editor_Destroy", entityType)) .ServerOperation(false)); } }@(Html.SavitarCRUDGrid<ReefType>("Grid1") .BindTo(Model) .Columns(columns => { columns.Bound(p => p.Description); }) )