public DefaultServerGridProcessor(TagHelperContext context, TagHelperOutput output, GridTagHelper tag, GridOptions options, ContextualizedHelpers helpers) { this.context = context; this.output = output; this.tag = tag; this.options = options; this.helpers = helpers; basePrefix = tag.For.Name; AdjustColumns(); }
public override async Task ProcessAsync(TagHelperContext context, TagHelperOutput output) { //estabilish context if (For == null) throw new ArgumentNullException(ForAttributeName); if (RequiredFunctionalities == null) { if(Type == GridType.Immediate) RequiredFunctionalities = (x) => Functionalities.FullDetail; else RequiredFunctionalities = (x) => Functionalities.FullInLine; } string fullName = ViewContext.ViewData.TemplateInfo.GetFullHtmlFieldName(For.Name); string id = OverrideId ?? TagBuilder.CreateSanitizedId(fullName, IdAttributeDotReplacement); var currProvider = ViewContext.TagHelperProvider(); var actTagName = TagName + (Type == GridType.Batch ? "-batch" : "-immediate"); var defaultTemplates = currProvider.GetDefaultTemplates(actTagName); var ctx = new ContextualizedHelpers(ViewContext, html, httpAccessor, component, urlHelperFactory, factory); // //get row definitions IList<RowType> rows = string.IsNullOrEmpty(RowsCacheKey) ? null : RowType.GetRowsCollection(RowsCacheKey); var nc = new ReductionContext(TagTokens.RowContainer, 0,defaultTemplates, rows != null); context.SetChildrenReductionContext(nc); await output.GetChildContentAsync(); var collector = new RowContainerCollector(nc); var res= collector.Process(this, defaultTemplates) as Tuple<IList<RowType>, IList<KeyValuePair<string, string>>>; if (rows == null) { rows = res.Item1; if (!string.IsNullOrEmpty(RowsCacheKey)) RowType.CacheRowGroup(RowsCacheKey, rows, httpAccessor.HttpContext); foreach(var row in rows) { if(row.ControllerType != null) { Action action = () => { ControllerHelpers.DeclareServerRowtype(row.ControllerType, row); }; CacheViewPartsFilter.AddAction(httpAccessor.HttpContext, action); } } } var toolbars = res.Item2; // //Prepare grid options var options = new GridOptions(rows, toolbars, Type, id, fullName) { CssClass=CssClass, ErrorMessages=ErrorMessages, ClientRowSelection=ClientRowSelection, ServerRowSelection=ServerRowSelection, LayoutTemplate=defaultTemplates.GetLayoutTemplate(LayoutTemplate), SubTemplates=defaultTemplates.GetLayoutParts(LayoutParts) }; //finally process! await currProvider.GetTagProcessor(actTagName)(context, output, this, options, ctx); }