Exemplo n.º 1
0
        /// <summary>
        /// Renders the jQuery(document).ready part of the grid
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="gridSpec"></param>
        /// <param name="gridName"></param>
        /// <param name="optionalGridDataUrl"></param>
        /// <param name="splitAtColumn"></param>
        /// <param name="dhtmlxGridResizeType"></param>
        /// <returns></returns>
        private static string RenderGridJavascriptDocumentReady <T>(GridSpec <T> gridSpec, string gridName, string optionalGridDataUrl, int?splitAtColumn, DhtmlxGridResizeType dhtmlxGridResizeType)
        {
            const string indent = "            ";
            var          gridColumnsJavascriptFunctions = BuildGridColumns(gridSpec, indent);
            var          dataUrlReadyForJavascript      = String.IsNullOrWhiteSpace(optionalGridDataUrl) ? "null" : $"\"{optionalGridDataUrl}\"";
            var          useSmartRendering = IsUsingSmartRendering(gridSpec);
            var          splitAtColumnJavascriptVariable = (splitAtColumn != null) ? splitAtColumn.ToString() : "null";

            var resizeGridFunction = dhtmlxGridResizeType == DhtmlxGridResizeType.VerticalFillHorizontalAutoFit
                ? GenerateVerticalFillResizeGridFunction(gridName)
                : string.Empty;

            var verticalResizeFunction = dhtmlxGridResizeType == DhtmlxGridResizeType.VerticalResizableHorizontalAutoFit
                ? GenerateVerticallyResizableFunction(gridName)
                : string.Empty;

            var result = String.Format(GridJavascriptDocumentReady,
                                       gridName,
                                       Skin,
                                       SkinRowHeight,
                                       gridColumnsJavascriptFunctions,
                                       gridSpec.ColumnFilterListForJavascript,
                                       gridSpec.GetColumnTotals(gridName),
                                       string.IsNullOrWhiteSpace(gridSpec.GroupingHeader) ? "null" : $"\"{gridSpec.GroupingHeader}\"",
                                       dataUrlReadyForJavascript,
                                       useSmartRendering.ToString().ToLower(),
                                       splitAtColumnJavascriptVariable,
                                       gridSpec.ShowFilterBar.ToString().ToLower(),
                                       gridSpec.GridInstructionsWhenEmpty,
                                       verticalResizeFunction,
                                       resizeGridFunction);

            return(result);
        }
Exemplo n.º 2
0
        private static string CreateGridHeaderIconsHtml <T>(GridSpec <T> gridSpec, string gridName, UrlTemplate <string> excelDownloadUrl)
        {
            var filteredExcelDownloadIconHtml = CreateFilteredExcelDownloadIconHtml(gridName, excelDownloadUrl);
            var customExcelDownloadIconHtml   = CreateFullDatabaseExcelDownloadIconHtml(gridName, gridSpec.CustomExcelDownloadUrl, gridSpec.CustomExcelDownloadLinkText ?? "Download Full Database");
            var createIconHtml          = CreateCreateUrlHtml(gridSpec.CreateEntityUrl, gridSpec.CreateEntityUrlClass, gridSpec.CreateEntityModalDialogForm, gridSpec.CreateEntityActionPhrase, gridSpec.ObjectNameSingular);
            var tagIconHtml             = CreateTagUrlHtml(gridName, gridSpec.BulkTagModalDialogForm);
            var generateReportsIconHtml = (gridSpec.GenerateReportModalDialogForm != null) ? CreateGenerateReportUrlHtml(gridName, gridSpec.GenerateReportModalDialogForm) : null;
            var arbitraryHtml           = CreateArbitraryHtml(gridSpec.ArbitraryHtml, "    ");

            return($@"
            {
                    (!string.IsNullOrWhiteSpace(arbitraryHtml)
                        ? $"<span>{arbitraryHtml}</span>"
                        : string.Empty)
                }
            {
                    (!string.IsNullOrWhiteSpace(createIconHtml)
                        ? $"<span>{createIconHtml}</span>"
                        : string.Empty)
                }
            {(!string.IsNullOrWhiteSpace(generateReportsIconHtml) ? $"<span>{generateReportsIconHtml}</span>" : string.Empty)}
            {(!string.IsNullOrWhiteSpace(tagIconHtml) ? $"<span>{tagIconHtml}</span>" : string.Empty)}
            {
                    (!string.IsNullOrWhiteSpace(filteredExcelDownloadIconHtml)
                        ? $"<span>{filteredExcelDownloadIconHtml}</span>"
                        : string.Empty)
                }
            {
                    (!string.IsNullOrWhiteSpace(customExcelDownloadIconHtml)
                        ? $"<span>{customExcelDownloadIconHtml}</span>"
                        : string.Empty)
                }");
        }
        public static string BuildDhtmlxGridHeader <T>(GridSpec <T> gridSpec, string gridName, UrlTemplate <string> excelDownloadWithFooterUrl, UrlTemplate <string> excelDownloadWithoutFooterUrl)
        {
            var filteredStateHtml   = CreateFilteredStateHtml(gridName, gridSpec.ShowFilterBar);
            var gridHeaderIconsHtml = CreateGridHeaderIconsHtml(gridSpec, gridName, excelDownloadWithFooterUrl, excelDownloadWithoutFooterUrl);

            return($@"
    <span class=""record-count"">
        {CreateViewingRowCountGridHeaderHtml(gridName, gridSpec.ObjectNamePlural)}
        {filteredStateHtml}
    </span>
    <span class=""actions pull-right"">
    {gridHeaderIconsHtml}
    </span>");
        }
Exemplo n.º 4
0
        public static string BuildDhtmlxGridHeader <T>(GridSpec <T> gridSpec, string gridName, UrlTemplate <string> excelDownloadUrl)
        {
            var filteredStateHtml   = CreateFilteredStateHtml(gridName, gridSpec.ShowFilterBar);
            var gridHeaderIconsHtml = CreateGridHeaderIconsHtml(gridSpec, gridName, excelDownloadUrl);

            return($@"
    <span class=""record-count"">
        {CreateViewingRowCountGridHeaderHtml(gridName, gridSpec.ObjectNamePlural)}
        {filteredStateHtml}
    </span>
    <span class=""checked-checkboxes"" style=""display:none;margin-left:20px;"">
        {CreateViewingCheckedCheckboxesCountGridHeaderHtml(gridName, gridSpec.ObjectNamePlural)}
    </span>
    <span class=""actions pull-right"">
    {gridHeaderIconsHtml}
    </span>");
        }
        public static string DhtmlxGridImpl <T>(GridSpec <T> gridSpec, string gridName, string optionalGridDataUrl, string styleString, int?splitAtColumn, string metaDivHtml, DhtmlxGridResizeType dhtmlxGridResizeType)
        {
            const string template =
                @"
<div id =""{0}ContainerDivID"" style=""position:relative;"">
    <div id=""{0}LoadingBar"" class=""project-firma-loading-bar"" style=""display:none"">{1}</div>
    <div id=""{0}MetaDivID"" class=""DhtmlxGridMeta"">{2}</div>
    <div id=""{0}DivID"" style=""{3}""></div>
    <script type=""text/javascript"">
    // <![CDATA[
        {4}
    // ]]>
    </script>
</div>";
            var javascriptDocumentReadyHtml = RenderGridJavascriptDocumentReady(gridSpec, gridName, optionalGridDataUrl,
                                                                                splitAtColumn, dhtmlxGridResizeType);

            return(String.Format(template, gridName, gridSpec.LoadingBarHtml, metaDivHtml, styleString, javascriptDocumentReadyHtml));
        }
        private static string CreateGridHeaderIconsHtml <T>(GridSpec <T> gridSpec, string gridName, UrlTemplate <string> excelDownloadWithFooterUrl, UrlTemplate <string> excelDownloadWithoutFooterUrl)
        {
            var clearCookiesIconHtml          = CreateClearAllCookiesIconHtml(gridName);
            var filteredExcelDownloadIconHtml = CreateFilteredExcelDownloadIconHtml(gridName, gridSpec.HasColumnTotals, excelDownloadWithFooterUrl, excelDownloadWithoutFooterUrl);
            var customExcelDownloadIconHtml   = CreateFullDatabaseExcelDownloadIconHtml(gridName, gridSpec.CustomExcelDownloadUrl, gridSpec.CustomExcelDownloadLinkText ?? "Download Full Database");
            var createIconHtml = CreateCreateUrlHtml(gridSpec.CreateEntityUrl, gridSpec.CreateEntityUrlClass, gridSpec.CreateEntityModalDialogForm, gridSpec.CreateEntityActionPhrase, gridSpec.ObjectNameSingular);
            var tagIconHtml    = CreateTagUrlHtml(gridName, gridSpec.BulkTagModalDialogForm);
            var arbitraryHtml  = CreateArbitraryHtml(gridSpec.ArbitraryHtml, "    ");

            return($@"
            {
                    (!string.IsNullOrWhiteSpace(arbitraryHtml)
                        ? $"<span>{arbitraryHtml}</span>"
                        : string.Empty)
                }
            {
                    (!string.IsNullOrWhiteSpace(createIconHtml)
                        ? $"<span>{createIconHtml}</span>"
                        : string.Empty)
                }
            {(!string.IsNullOrWhiteSpace(tagIconHtml) ? $"<span>{tagIconHtml}</span>" : string.Empty)}
            {
                    (!string.IsNullOrWhiteSpace(clearCookiesIconHtml)
                        ? $"<span>{clearCookiesIconHtml}</span>"
                        : string.Empty)
                }
            {
                    (!string.IsNullOrWhiteSpace(filteredExcelDownloadIconHtml)
                        ? $"<span>{filteredExcelDownloadIconHtml}</span>"
                        : string.Empty)
                }
            {
                    (!string.IsNullOrWhiteSpace(customExcelDownloadIconHtml)
                        ? $"<span>{customExcelDownloadIconHtml}</span>"
                        : string.Empty)
                }");
        }
 public static string DhtmlxGridImpl <T>(GridSpec <T> gridSpec, string gridName, string optionalGridDataUrl, string styleString, int?splitAtColumn)
 {
     return(DhtmlxGridImpl(gridSpec, gridName, optionalGridDataUrl, styleString, splitAtColumn, string.Empty, DhtmlxGridResizeType.None));
 }
 /// <summary>
 /// Only public for unit testing
 /// </summary>
 /// <typeparam name="T"></typeparam>
 /// <param name="gridSpec"></param>
 /// <param name="gridName"></param>
 /// <param name="optionalGridDataUrl"></param>
 /// <param name="styleString"></param>
 /// <returns></returns>
 public static HtmlString DhtmlxGrid <T>(GridSpec <T> gridSpec, string gridName, string optionalGridDataUrl, string styleString)
 {
     return(new HtmlString(DhtmlxGridImpl(gridSpec, gridName, optionalGridDataUrl, styleString, null, string.Empty, DhtmlxGridResizeType.None)));
 }
 /// <summary>
 /// Determines if the grid should be using smart rendering
 /// </summary>
 /// <typeparam name="T"></typeparam>
 /// <param name="gridSpec"></param>
 /// <returns></returns>
 public static bool IsUsingSmartRendering <T>(GridSpec <T> gridSpec)
 {
     return(!gridSpec.HasColumnTotals);
 }