示例#1
0
        public ActionResult GridFilter(MyViewModel vm)
        {
            var result = new JsonResult();

            if (!Request.IsAjaxRequest())
            {
                result.Data = new { statuscode = "400", error = "Invalid Request" };
                return(result);
            }


            var query = GetDummy().AsQueryable();

            //generic sort
            query = SortingService.GenericSortQuery <Person>(query, vm);
            //generic sort
            if (vm.FreeText.IsNotEmpty() && vm.FreeText.ToList().Count > 4)
            {
                query = FilterService.AppendQueryWithContains <Person>("PhoneNr", vm.FreeText.ToLower(), query, vm.AsSortingFilterModel);
            }
            //generic paging
            query = FilterService.GenericPaging(query, vm.AsSortingFilterModel);

            //return data
            vm.Persons = query.ToList();

            ModelState.Clear();
            var modalViewStr = this.GetPartialViewAsStr("_Grid", vm);

            result.Data = new { statuscode = "200", data = modalViewStr };
            return(result);
        }