Ejemplo n.º 1
0
        public static string PagingMgrGrid(this HtmlHelper htmlHelper, PagingMgr pagingMgr)
        {
            // Get the pagingState and pagingDirection
            var    route           = htmlHelper.ViewContext.RouteData;
            var    controllerName  = route.GetRequiredString("controller");
            var    actionName      = route.GetRequiredString("action");
            string pagingState     = htmlHelper.ViewContext.HttpContext.Request.Params["pagingState"];
            string pagingDirection = htmlHelper.ViewContext.HttpContext.Request.Params["pagingDirection"];

            PagingMgr.PagingDbCmdEnum pagingOption = string.IsNullOrWhiteSpace(pagingDirection) ?
                                                     PagingMgr.PagingDbCmdEnum.First :
                                                     (PagingMgr.PagingDbCmdEnum)Enum.Parse(typeof(PagingMgr.PagingDbCmdEnum), pagingDirection);

            if (!string.IsNullOrWhiteSpace(pagingState))
            {
                // Set the pagingState before getting the intended page
                pagingMgr.RestorePagingState(pagingState);

//                string initHtml = @"
//
//function showPage(action, data) {{
//    $.ajax({{
//        url: action,
//        type: ""get"",
//        format: ""html"",
//        cache: false,
//        data: data,
//        success: function (result) {{
//            // alert(result);
//            $(""#gridContainer"").html(result);
//        }},
//        error: function (xhr, status, error) {{
//
//            //?? CALL the client side error handling function which may be provided by the client
//
//            alert(xhr.responseText);
//            //?? showModalDialog(xhr.statusText, xhr.responseText);
//        }}
//    }});
//}}
//
//";
            }

            // Set the paging option and get the next page
            DataTable             pageTable = pagingMgr.GetPage(pagingOption);
            IEnumerable <dynamic> pageData  = DataTableToEnumerable(pageTable);

            // Realize the loop
            WebGrid webGrid = new WebGrid(pageData, rowsPerPage: pagingMgr.PageSize);

            // Get the new paging state for next and previous link
            string newPagingState = pagingMgr.GetPagingState();
            string html           =
                string.Format("<a href=\"/OurAdminWeb/Grid/TestSequences?pagingState={0}&pagingDirection={1}\">Previous</a>", newPagingState, "prev")
                + " | "
                + string.Format("<a href=\"/OurAdminWeb/Grid/TestSequences?pagingState={0}&pagingDirection={1}\">Next</a><br />", newPagingState, "next");

            return(html + webGrid.Table().ToHtmlString());
        }
Ejemplo n.º 2
0
        public static string ToHtmlString(this PagingMgr pagingMgr, Controller mvcController)
        {
            // Get the pagingState and pagingDirection
            var    route           = mvcController.RouteData;
            var    controllerName  = route.GetRequiredString("controller");
            var    actionName      = route.GetRequiredString("action");
            string pagingState     = mvcController.Request.Params["pagingState"];
            string pagingDirection = mvcController.Request.Params["pagingDirection"] ?? "first";

            // Set the pagingState before getting the intended page
            pagingMgr.RestorePagingState(pagingState);

            // Set the paging option and get the next page
            PagingMgr.PagingDbCmdEnum pagingOption = pagingDirection == "first" ? PagingMgr.PagingDbCmdEnum.First
                : pagingDirection == "next" ? PagingMgr.PagingDbCmdEnum.Next
                : pagingDirection == "prev" ? PagingMgr.PagingDbCmdEnum.Previous
                : PagingMgr.PagingDbCmdEnum.Last;
            DataTable             pageTable = pagingMgr.GetPage(pagingOption);
            IEnumerable <dynamic> pageData  = DataTableToEnumerable(pageTable);

            // Realize the loop
            WebGrid webGrid = new WebGrid(pageData, rowsPerPage: pagingMgr.PageSize);

            // Get the new paging state for next and previous link
            string newPagingState = pagingMgr.GetPagingState();
            string html           =
                string.Format("<a href=\"/OurAdminWeb/Grid/TestSequences?pagingState={0}&pagingDirection={1}\">Previous</a>", newPagingState, "prev")
                + " | "
                + string.Format("<a href=\"/OurAdminWeb/Grid/TestSequences?pagingState={0}&pagingDirection={1}\">Next</a><br />", newPagingState, "next");

            return(html + webGrid.Table().ToHtmlString());
        }
Ejemplo n.º 3
0
        public static IHtmlString ToHtmlString <T>(this PagingMgr pagingMgr, PagingMgr.PagingDbCmdEnum pagingDirection)
            where T : new()
        {
            IEnumerable <dynamic> pageData = (IEnumerable <dynamic>)pagingMgr.GetPage <T>(pagingDirection);
            WebGrid webGrid = new WebGrid(pageData);

            return(webGrid.Table());
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Sets the grid to contain the page of data of given direction for the given page size
        /// using the given pagingMgr.
        /// </summary>
        /// <param name="pagingMgr">PagingMgr object instance</param>
        /// <param name="pageDirection">Paging enumeration: First, Last, Next, Previou</param>
        /// <param name="pageSize">Number of records to be loaded in a page</param>
        /// <returns>Bool indicator of whether there was data loaded into grid</returns>
        private bool SetPage(PagingMgr pagingMgr, PagingMgr.PagingDbCmdEnum?pageDirection, short pageSize)
        {
            if (pagingMgr == null)
            {
                throw new ILoggingManagement.ExceptionEvent(ILoggingManagement.enumExceptionEventCodes.NullOrEmptyParameter
                                                            , "pagingMgr cannot be null");
            }

            DataTable page = pageDirection.HasValue ? pagingMgr.GetPage(pageDirection.Value, pageSize)
                : pagingMgr.RefreshPage(pageSize);

            if (page != null && page.Rows.Count > 0)
            {
                dataGridPaging.ItemsSource = page.DefaultView;
                lblPagingGridMsg.Content   = string.Empty;
                return(true);
            }
            lblPagingGridMsg.Content = "No more data found.";
            return(false);
        }