public override async Task ProcessAsync(TagHelperContext context, TagHelperOutput output) { var columnGroupContext = (DataTableColumnGroupContext)context.Items[typeof(DataTableColumnGroupContext)]; var mergedColumnContext = new DataTableColumnGroupContext(); context.Items[typeof(DataTableColumnGroupContext)] = mergedColumnContext; await output.GetChildContentAsync(); Column.Searchable = false; //TODO add support Column.Orderable = false; //TODO add support var renderFunction = new StringBuilder(); renderFunction.AppendLine("function(data, type, row, meta) {"); renderFunction.AppendLine(" var ret = '';"); foreach (var column in mergedColumnContext.Columns) { renderFunction.AppendFormat( " ret += {0}(row{1}, type, row, meta);", column.Render ?? "function(data){return data;}", column.Data?.Insert(0, ".") ).AppendLine(); } renderFunction.AppendLine(" return ret;"); renderFunction.Append("}"); Column.Render = renderFunction.ToString(); columnGroupContext.Columns.Add(Column); output.SuppressOutput(); }
public override async Task ProcessAsync(TagHelperContext context, TagHelperOutput output) { var columnGroupContext = new DataTableColumnGroupContext(); context.Items[typeof(DataTableColumnGroupContext)] = columnGroupContext; await output.GetChildContentAsync(); var dataTableContext = (DataTableContext)context.Items[typeof(DataTableContext)]; var options = dataTableContext.Options; options.Columns = options.Columns.Union(columnGroupContext.Columns).ToArray(); output.SuppressOutput(); }