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));
        }
예제 #2
0
        /// <summary>
        /// All grids use this
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="html"></param>
        /// <param name="gridSpec"></param>
        /// <param name="gridName"></param>
        /// <param name="optionalGridDataUrl"></param>
        /// <param name="styleString"></param>
        /// <param name="dhtmlxGridResizeType"></param>
        /// <returns></returns>
        public static HtmlString DhtmlxGrid <T>(this HtmlHelper html, GridSpec <T> gridSpec, string gridName, string optionalGridDataUrl, string styleString, DhtmlxGridResizeType dhtmlxGridResizeType)
        {
            var dhtmlxGridHeader = DhtmlxGridHtmlHelpers.BuildDhtmlxGridHeader(gridSpec, gridName, ExcelDownloadWithFooterUrl, ExcelDownloadWithoutFooterUrl);

            var dhtmlxGrid = DhtmlxGridHtmlHelpers.DhtmlxGridImpl(gridSpec,
                                                                  gridName,
                                                                  optionalGridDataUrl,
                                                                  $"background-color:white;{styleString}",
                                                                  null, dhtmlxGridHeader, dhtmlxGridResizeType);

            return(new HtmlString(dhtmlxGrid));
        }
        /// <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 columnsToHideString = BuildGridColumnHiddens(gridSpec);

            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,
                                       columnsToHideString);

            return(result);
        }
        /// <summary>
        /// All grids use this
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="html"></param>
        /// <param name="gridSpec"></param>
        /// <param name="gridName"></param>
        /// <param name="optionalGridDataUrl"></param>
        /// <param name="styleString"></param>
        /// <param name="dhtmlxGridResizeType"></param>
        /// <returns></returns>
        public static HtmlString DhtmlxGrid <T>(this HtmlHelper html, GridSpec <T> gridSpec, string gridName, string optionalGridDataUrl, string styleString, DhtmlxGridResizeType dhtmlxGridResizeType)
        {
            var dhtmlxGridHeader = DhtmlxGridHtmlHelpers.BuildDhtmlxGridHeader(gridSpec, gridName, ExcelDownloadUrl);

            var saveGridSettingsUrl = SitkaRoute <GridSettingsController> .BuildUrlFromExpression(c => c.SaveGridSettings());

            var dhtmlxGrid = DhtmlxGridHtmlHelpers.DhtmlxGridImpl(gridSpec,
                                                                  gridName,
                                                                  optionalGridDataUrl,
                                                                  $"background-color:white;{styleString}",
                                                                  null, dhtmlxGridHeader, dhtmlxGridResizeType, saveGridSettingsUrl);

            return(new HtmlString(dhtmlxGrid));
        }