public ActionResult Read([CustomDataSourceRequest] CustomDataSourceRequest request) { DataTable orders = DynamicTable(request.TableName, request.ParentFieldName, request.ParentFieldValue); if (request.Aggregates.Any()) { request.Aggregates.Each(agg => { agg.Aggregates.Each(a => { a.MemberType = orders.Columns[agg.Member].DataType; }); }); } return(Json(orders.ToDataSourceResult(request))); }
public object BindModel(ControllerContext controllerContext, ModelBindingContext bindingContext) { DataSourceRequestModelBinder originalBinder = new DataSourceRequestModelBinder(); DataSourceRequest originalRequest = (DataSourceRequest)originalBinder.BindModel(controllerContext, bindingContext); CustomDataSourceRequest request = new CustomDataSourceRequest() { Aggregates = originalRequest.Aggregates, Filters = originalRequest.Filters, Groups = originalRequest.Groups, PageSize = originalRequest.PageSize, Page = originalRequest.Page, Sorts = originalRequest.Sorts }; string tableName; string parentFieldName; string parentFieldValue; if (TryGetValue(bindingContext, "tableName", out tableName)) { request.TableName = tableName; } if (TryGetValue(bindingContext, "parentFieldName", out parentFieldName)) { request.ParentFieldName = parentFieldName; } if (TryGetValue(bindingContext, "parentFieldValue", out parentFieldValue)) { request.ParentFieldValue = parentFieldValue; } return(request); }