Example #1
0
 public ActionResult Index()
 {
     ViewBag.columns = KendoGridHelper.GenColumns <VMUser>();
     ViewBag.models  = KendoGridHelper.GenModels <VMUser>();
     ViewBag.create  = KendoGridHelper.GenCreateForm <VMUser>();
     return(View());
 }
        public Task BindModelAsync(ModelBindingContext bindingContext)
        {
            KendoDataSourceRequest request = new KendoDataSourceRequest();

            string sort, group, filter /*, aggregates*/;
            int    currentPage;
            int    pageSize;

            KendoGridHelper helper = new KendoGridHelper(_namingService);

            if (TryGetValue(bindingContext, "page", out currentPage))
            {
                request.Page = currentPage;
            }

            if (TryGetValue(bindingContext, "pageSize", out pageSize))
            {
                request.PageSize = pageSize;
            }

            if (TryGetValue(bindingContext, "sort", out sort))
            {
                request.Sorts = helper.Deserialize <SortDescriptor>(sort);
            }

            if (TryGetValue(bindingContext, "filter", out filter))
            {
                request.FilterWrapper = helper.ParseFilter(filter);
            }

            if (TryGetValue(bindingContext, "group", out group))
            {
                request.Groups = helper.Deserialize <GroupDescriptor>(group);
            }

            //if (TryGetValue(bindingContext, GridUrlParameters.Aggregates, out aggregates))
            //{
            //    request.Aggregates = GridDescriptorSerializer.Deserialize<AggregateDescriptor>(aggregates);
            //}

            bindingContext.Result = ModelBindingResult.Success(request);

            return(Task.CompletedTask);
        }