/// <summary> /// Gets the base page HTML. /// </summary> /// <param name="helper">The helper.</param> /// <param name="gridName">Name of the grid.</param> /// <param name="grid">The grid.</param> /// <param name="pageParameters">The page parameters.</param> /// <returns>System.String.</returns> /// TODO Edit XML Comment Template for GetBasePageHtml public string GetBasePageHtml( HtmlHelper helper, string gridName, IMvcGridDefinition grid, object pageParameters) { var preload = ""; if (grid.QueryOnPageLoad && grid.PreloadData) { try { preload = RenderPreloadedGridHtml( helper, grid, gridName, pageParameters); } catch (Exception ex) { var showDetails = ConfigUtility .GetShowErrorDetailsSetting(); if (showDetails) { var detail = "<div class='alert alert-danger'>"; detail += HttpUtility.HtmlEncode(ex.ToString()) .Replace("\r\n", "<br />"); detail += "</div>"; preload = detail; } else { preload = grid.ErrorMessageHtml; } } } var baseGridHtml = MvcGridHtmlGenerator.GenerateBasePageHtml( gridName, grid, pageParameters); baseGridHtml = baseGridHtml.Replace("%%PRELOAD%%", preload); var containerRenderingModel = new ContainerRenderingModel { InnerHtmlBlock = baseGridHtml }; var html = RenderContainerHtml(helper, grid, containerRenderingModel); return(html); }
public void Init() { if (!_init) { lock (_lock) { if (!_init) { _cachedBinaryResources = new Dictionary <string, byte[]>(); _cachedTextResources = new Dictionary <string, string>(); string script = GetTextResource("MVCGrid.js"); var handlerPath = HttpContext.Current.Request.CurrentExecutionFilePath; script = script.Replace("%%HANDLERPATH%%", handlerPath); bool showErrorDetails = ConfigUtility.GetShowErrorDetailsSetting(); script = script.Replace("%%ERRORDETAILS%%", showErrorDetails.ToString().ToLower()); var controllerPath = HttpContext.Current.Request.ApplicationPath; controllerPath += "mvcgrid/grid"; try { var urlHelper = new System.Web.Mvc.UrlHelper(HttpContext.Current.Request.RequestContext); controllerPath = urlHelper.Action("Grid", "MVCGrid"); } catch { } script = script.Replace("%%CONTROLLERPATH%%", controllerPath); _cachedTextResources.Add("MVCGrid.js", script); _cachedTextResources.Add("spin.min.js", GetTextResource("spin.min.js")); _cachedBinaryResources.Add("sort.png", GetBinaryResource("sort.png")); _cachedBinaryResources.Add("sortdown.png", GetBinaryResource("sortdown.png")); _cachedBinaryResources.Add("sortup.png", GetBinaryResource("sortup.png")); _init = true; } } } }
public string GetBasePageHtml(string gridName, IMVCGridDefinition grid, object pageParameters) { string preload = ""; if (grid.QueryOnPageLoad && grid.PreloadData) { try { preload = RenderPreloadedGridHtml(grid, gridName, pageParameters); } catch (Exception ex) { bool showDetails = ConfigUtility.GetShowErrorDetailsSetting(); if (showDetails) { string detail = "<div class='alert alert-danger'>"; detail += HttpUtility.HtmlEncode(ex.ToString()).Replace("\r\n", "<br />"); detail += "</div>"; preload = detail; } else { preload = grid.ErrorMessageHtml; } } } string rootUrl = HtmlUtility.GetRootUrl(); string baseGridHtml = MVCGridHtmlGenerator.GenerateBasePageHtml(gridName, grid, pageParameters, HtmlUtility.GetHandlerPath(rootUrl)); baseGridHtml = baseGridHtml.Replace("%%PRELOAD%%", preload); ContainerRenderingModel containerRenderingModel = new ContainerRenderingModel() { InnerHtmlBlock = baseGridHtml }; string html = RenderContainerHtml(grid, gridName, containerRenderingModel); return(html); }
/// <summary> /// Initializes this instance. /// </summary> /// TODO Edit XML Comment Template for Init public void Init() { if (_init) { return; } lock (Lock) { if (_init) { return; } _cachedBinaryResources = new Dictionary <string, byte[]>(); _cachedTextResources = new Dictionary <string, string>(); var script = GetTextResource("MVCGrid.js"); var handlerPath = HttpContext.Current.Request .CurrentExecutionFilePath; script = script.Replace("%%HANDLERPATH%%", handlerPath); var showErrorDetails = ConfigUtility.GetShowErrorDetailsSetting(); script = script.Replace( "%%ERRORDETAILS%%", showErrorDetails.ToString().ToLower()); var controllerPath = HttpContext.Current.Request .ApplicationPath; controllerPath += "mvcgrid/grid"; try { var urlHelper = new UrlHelper( HttpContext.Current.Request.RequestContext); controllerPath = urlHelper.Action("Grid", "MVCGrid"); } catch (Exception e) { Debug.WriteLine(e); } script = script.Replace("%%CONTROLLERPATH%%", controllerPath); _cachedTextResources.Add("MVCGrid.js", script); _cachedBinaryResources.Add( "ajaxloader.gif", GetBinaryResource("ajaxloader.gif")); _cachedBinaryResources.Add( "sort.png", GetBinaryResource("sort.png")); _cachedBinaryResources.Add( "sortdown.png", GetBinaryResource("sortdown.png")); _cachedBinaryResources.Add( "sortup.png", GetBinaryResource("sortup.png")); _init = true; } }