Exemple #1
0
        private void AppendTableHtml(StringBuilder sb, DataTableContext tableContext, TagHelperContext context)
        {
            Contract.Requires(sb != null && tableContext != null && context != null);

            var classes = "";

            if (context.AllAttributes.TryGetAttribute("class", out TagHelperAttribute classTag))
            {
                classes = classTag.Value.ToString();
            }

            classes += " dt-table";

            sb.AppendLine($"<table id=\"{TableId}\" class=\"{classes}\" cellspacing=\"0\" width=\"100%\">");
            sb.AppendLine("<thead>");
            sb.AppendLine("<tr>");
            if (tableContext.ColumnsProperties != null)
            {
                //foreach (var columnProperty in tableContext.ColumnsProperties)
                //{
                //    sb.AppendLine($"<th>{columnProperty.Metadata?.DisplayName}</th>");
                //}
            }
            if (tableContext.ActionDataSet != null && tableContext.ActionDataSet.Any())
            {
                sb.AppendLine("<th></th>");
            }
            sb.AppendLine("</tr>");
            sb.AppendLine("</thead>");
            sb.AppendLine("</table>");
        }
Exemple #2
0
        //private void TableBody(TagHelperOutput output, DataTableContext tableContext)
        //{
        //    output.Content.AppendHtml("<tbody>");

        //    foreach (var item in Items)
        //    {
        //        output.Content.AppendHtml("<tr>");
        //        foreach (var prop in props)
        //        {
        //            var value = GetPropertyValue(prop, item);
        //            output.Content.AppendHtml($"<td>{value}</td>");
        //        }
        //        output.Content.AppendHtml("</tr>");
        //    }

        //    output.Content.AppendHtml("</tbody>");
        //}
        private void AppendInitializeFunction(StringBuilder sb, DataTableContext tableContext, string initializeFunctionName)
        {
            sb.AppendLine("function " + initializeFunctionName + "(){");
            sb.AppendLine($"$('#{TableId}').DataTable({{");

            var localizationUrl = "http://cdn.datatables.net/plug-ins/1.10.13/i18n/Portuguese-Brasil.json"; // _localizer["LocalizationUrl"];

            if (!string.IsNullOrEmpty(localizationUrl))
            {
                sb.AppendLine($"language: {{url: \"{localizationUrl}\"}},");
            }

            if (ServerSide)
            {
                AppendServerSideProcessingData(sb);
            }
            else if (!string.IsNullOrEmpty(JsonData))
            {
                AppendData(sb);
            }
            else
            {
                throw new NotImplementedException();
            }

            //AppendColumns(sb, tableContext);

            sb.AppendLine("});");
            sb.AppendLine("}");
        }
Exemple #3
0
        private async Task <DataTableContext> GetTableContextAsync(TagHelperContext context, TagHelperOutput output)
        {
            Contract.Requires(context != null && output != null);

            var tableContext = new DataTableContext {
                ModelExplorer = GetModelExplorer(ModelType)
            };

            context.Items.Add(typeof(DataTableTagHelper), tableContext);

            await output.GetChildContentAsync();

            return(tableContext);
        }
Exemple #4
0
        private void TableHeader(TagHelperOutput output, DataTableContext tableContext)
        {
            output.Content.AppendHtml("<thead>");
            output.Content.AppendHtml("<tr>");

            //if (tableContext.ColumnsProperties != null)
            //{
            //    foreach (var columnProperty in tableContext.ColumnsProperties)
            //    {
            //        output.Content.AppendHtml($"<th>{columnProperty.Metadata?.DisplayName}</th>");
            //    }
            //}

            output.Content.AppendHtml("</tr>");
            output.Content.AppendHtml("</thead>");
        }