Ejemplo n.º 1
0
        /// <summary>
        /// 获取表格参数
        /// </summary>
        /// <returns></returns>
        public GridParams GetGridParams()
        {
            var grid    = new GridParams();
            var request = new HttpRequestExtension(HttpContext.Request);

            if (!string.IsNullOrEmpty(request["rows"]))
            {
                grid.PageSize = Int32.Parse(request["rows"]);
            }

            if (grid.PageSize == 0)
            {
                grid.PageSize = 10;
            }

            if (!string.IsNullOrEmpty(request["page"]))
            {
                grid.PageIndex = Int32.Parse(request["page"]);

                if (grid.PageIndex == 0)
                {
                    grid.PageIndex = 0;
                }
            }

            if (!string.IsNullOrEmpty(request["sort"]))
            {
                grid.SortField = request["sort"].ToString();
            }

            if (!string.IsNullOrEmpty(request["order"]))
            {
                grid.SortDirection = request["order"].ToString();
            }

            if (!string.IsNullOrEmpty(request["total"]) && request["total"] != "NaN")
            {
                grid.TotalCount = int.Parse(request["total"]);
            }

            if (!string.IsNullOrEmpty(request["gridFields"]))
            {
                grid.Columns = JSONHelper.FromJsonTo <List <GridColumn> >(request["gridFields"]);
            }

            return(grid);
        }
Ejemplo n.º 2
0
        public GridParams GetGridParams()
        {
            var grid = new GridParams();

            if (HttpContext.Request["rows"] != null)
            {
                grid.PageSize = Int32.Parse(HttpContext.Request["rows"].ToString());
            }

            if (grid.PageSize == 0)
            {
                grid.PageSize = 10;
            }

            if (HttpContext.Request["page"] != null)
            {
                grid.PageIndex = Int32.Parse(HttpContext.Request["page"].ToString());

                if (grid.PageIndex == 0)
                {
                    grid.PageIndex = 0;
                }
            }

            if (HttpContext.Request["sort"] != null)
            {
                grid.SortField = HttpContext.Request["sort"].ToString();
            }

            if (HttpContext.Request["order"] != null)
            {
                grid.SortDirection = HttpContext.Request["order"].ToString();
            }

            if (HttpContext.Request["total"] != null && HttpContext.Request["total"] != "NaN")
            {
                grid.TotalCount = int.Parse(HttpContext.Request["total"]);
            }

            if (HttpContext.Request["gridFields"] != null)
            {
                grid.Columns = JSONHelper.FromJsonTo <List <GridColumn> >(HttpContext.Request["gridFields"].ToString());
            }

            return(grid);
        }