@(Html.EJ().Grid<OrdersView>("FlatGrid") .Datasource(ds => ds.URL("/Grid/DataSource").Adaptor(AdaptorType.UrlAdaptor)) … public ActionResult DataSource(DataManager dm) { IEnumerable DataSource = new NorthwindDataContext().OrdersViews.ToList(); DataResult result = new DataResult(); DataOperations operation = new DataOperations(); result.result = DataSource; if (dm.Sorted != null && dm.Sorted.Count > 0) //Sorting { result.result = operation.PerformSorting(DataSource, dm.Sorted); } if (dm.Where != null && dm.Where.Count > 0) //Filtering { result.result = operation.PerformWhereFilter(DataSource, dm.Where, dm.Where[0].Operator); } result.count = result.result.AsQueryable().Count(); if (dm.Skip > 0) result.result = operation.PerformSkip(result.result, dm.Skip); if (dm.Take > 0) result.result = operation.PerformTake(result.result, dm.Take); return Json(result, JsonRequestBehavior.AllowGet); } |
The DataManager class helps in binding the Grid queries passed to the server-side. Based on those queries you can perform server-side operation on the Grid data. The query parameters that help you perform the server-side operations are as follows.
DataManager Operations: The query parameters are serialized by the DataManager class and the server-side operations such as sorting, filtering, paging are performed by the PerformSorting, PerfomWherFilter, PerformSkip and PerformTake methods. |