Exemplo n.º 1
0
        public ActionResult VirtualDataSource(DataManager dm)
        {
            IQueryable <OrdersView> datasource = new NorthwindDataContext().OrdersViews;
            var count = datasource.Count();

            if (dm.Skip >= 0)//for paging
            {
                datasource = QueryableDataOperations.PerformSkip(datasource, dm.Skip);
            }
            if (dm.Take > 0)//for paging
            {
                datasource = QueryableDataOperations.PerformTake(datasource, dm.Take);
            }
            return(Json(new { result = datasource.ToList(), count = count }));
        }
        public ActionResult CustomServerBinding([DataSourceRequest(Prefix = "Grid")] DataSourceRequest request)
        {
            if (request.PageSize == 0)
            {
                request.PageSize = 10;
            }

            IQueryable <Order> orders = new NorthwindDataContext().Orders;

            orders = orders.ApplyFiltering(request.Filters);

            var total = orders.Count();

            orders = orders.ApplySorting(request.Groups, request.Sorts);

            orders = orders.ApplyPaging(request.Page, request.PageSize);

            IEnumerable data = orders.ApplyGrouping(request.Groups);

            ViewData["total"] = total;

            return(View(data));
        }