protected override void BuildRenderTree(RenderTreeBuilder builder) { RenderFragment r = (b2) => { base.BuildRenderTree(b2); }; builder.OpenRegion(EditContext.GetHashCode() + 1); builder.OpenComponent <CascadingValue <EditFormPlus> >(1); builder.AddAttribute(2, "Value", this); builder.AddAttribute(3, "ChildContent", r); builder.CloseComponent(); builder.CloseRegion(); }
/// <inheritdoc /> protected override void BuildRenderTree(RenderTreeBuilder builder) { builder.OpenRegion(_fixedEditContext.GetHashCode()); builder.OpenElement(0, "form"); builder.AddMultipleAttributes(1, AdditionalAttributes); builder.AddAttribute(2, "onsubmit", _handleSubmitDelegate); builder.OpenComponent <CascadingValue <EditContext> >(3); builder.AddAttribute(4, "IsFixed", true); builder.AddAttribute(5, "Value", _fixedEditContext); builder.AddAttribute(6, "ChildContent", ChildContent?.Invoke(_fixedEditContext)); builder.CloseComponent(); builder.CloseElement(); builder.CloseRegion(); }
/// <summary> /// 构造表单内容。 /// </summary> /// <param name="builder"></param> protected override void BuildRenderTree(RenderTreeBuilder builder) { builder.OpenRegion(_fixedEditContext.GetHashCode()); builder.OpenElement(0, "form"); AddCommonAttributes(builder); builder.AddMultipleAttributes(1, AdditionalAttributes); builder.OpenComponent <CascadingValue <EditContext> >(2); builder.AddAttribute(3, "Value", _fixedEditContext); builder.AddAttribute(4, "IsFixed", true); builder.AddAttribute(5, nameof(ChildContent), ChildContent?.Invoke(_fixedEditContext)); builder.CloseComponent(); builder.CloseElement(); builder.CloseRegion(); }
/// <inheritdoc /> protected override void BuildRenderTree(RenderTreeBuilder builder) { // If _fixedEditContext changes, tear down and recreate all descendants. // This is so we can safely use the IsFixed optimization on CascadingValue, // optimizing for the common case where _fixedEditContext never changes. builder.OpenRegion(_fixedEditContext.GetHashCode()); builder.OpenElement(0, "form"); builder.AddMultipleAttributes(1, AdditionalAttributes); builder.AddAttribute(2, "id", Id); builder.AddAttribute(3, "onsubmit", _handleSubmitDelegate); builder.OpenComponent <CascadingValue <EditContext> >(4); builder.AddAttribute(5, "IsFixed", true); builder.AddAttribute(6, "Value", _fixedEditContext); builder.AddAttribute(7, "ChildContent", ChildContent?.Invoke(_fixedEditContext)); builder.CloseComponent(); builder.CloseElement(); builder.CloseRegion(); }
protected override void BuildRenderTree(RenderTreeBuilder builder) { base.BuildRenderTree(builder); // If _fixedEditContext changes, tear down and recreate all descendants. // This is so we can safely use the IsFixed optimization on Cascadi ngValue, // optimizing for the common case where _fixedEditContext never changes. builder.OpenRegion(mEditContext.GetHashCode()); if (!IsInTableRow) { builder.OpenElement(0, "form"); builder.AddMultipleAttributes(1, AdditionalAttributes); builder.AddAttribute(2, "onsubmit", EventCallback.Factory.Create(this, NotifyContainer)); if (EnableValidation) { builder.AddAttribute(11, "class", "m-form-validation"); } } if (Fields != null) { RenderFragment child3() => (builder2) => { builder2.AddMarkupContent(1, "\r\n"); builder2.AddContent(2, this.Fields); builder2.AddMarkupContent(3, "\r\n"); }; builder.OpenComponent <CascadingValue <MForm <T> > >(4); builder.AddAttribute(5, "Value", this); builder.AddAttribute(6, "ChildContent", child3()); builder.CloseComponent(); } RenderFragment child(EditContext context) => (builder2) => { if (EnableValidation) { builder2.OpenComponent <DataAnnotationsValidator>(0); builder2.CloseComponent(); } if (!IsInTableRow) { builder2.OpenComponent <ValidationSummary>(1); builder2.CloseComponent(); } if (FieldList.Any()) { foreach (var groupResult in FieldList.GroupBy(p => 0)) { Process(builder2, groupResult); } } else { foreach (var groupResult in ReflectionHelper.GetProperties(Model).Select(pi => GetField(pi)).GroupBy(p => { var rowAttr = p.Attributes?.FirstOrDefault(a => a.GetType() == typeof(RowAttribute)) as RowAttribute; if (rowAttr == null) { return(0); } return(rowAttr.RowId); }).OrderByDescending(g => g.Key).Reverse()) { // Console.WriteLine(property.PropertyType.FullName); Process(builder2, groupResult); } } if (!IsInTableRow) { builder2.AddMarkupContent(27, "<button type=\"submit\" style=\"display: none;\">Submit</button>\r\n"); } }; builder.OpenComponent <CascadingValue <EditContext> >(3); builder.AddAttribute(4, "IsFixed", true); builder.AddAttribute(5, "Value", mEditContext); builder.AddAttribute(6, "ChildContent", child(mEditContext)); builder.CloseComponent(); if (!IsInTableRow) { builder.CloseElement(); } builder.CloseRegion(); }
protected override void BuildRenderTree(RenderTreeBuilder builder) { base.BuildRenderTree(builder); // If _fixedEditContext changes, tear down and recreate all descendants. // This is so we can safely use the IsFixed optimization on Cascadi ngValue, // optimizing for the common case where _fixedEditContext never changes. builder.OpenRegion(mEditContext.GetHashCode()); if (!IsInTableRow) { builder.OpenElement(112, "div"); builder.AddAttribute(113, "data-form-id", Id.ToString()); string defaultCssClass = "m-form-container"; if (EnableValidation) { defaultCssClass += " m-form-validation"; } builder.AddAttribute(11, "class", RenderHelper.GetCssClass(AdditionalAttributes, defaultCssClass)); if (AdditionalAttributes != null) { builder.AddMultipleAttributes(1, AdditionalAttributes.Where(a => a.Key != "class")); } builder.OpenElement(0, "form"); builder.AddAttribute(1, "id", Id.ToString()); builder.AddMultipleAttributes(1, AdditionalAttributes); builder.AddAttribute(2, "onsubmit", EventCallback.Factory.Create(this, NotifyContainer)); if (EnableValidation) { builder.AddAttribute(11, "class", "m-form-validation"); } builder.CloseElement(); } RenderFragment child(EditContext context) => (builder2) => { if (Fields != null) { RenderFragment child3() => (builder3) => { builder3.AddMarkupContent(1, "\r\n"); builder3.AddContent(2, this.Fields); builder3.AddMarkupContent(3, "\r\n"); }; builder2.OpenComponent <CascadingValue <MForm <T> > >(4); builder2.AddAttribute(5, "Value", this); builder2.AddAttribute(6, "ChildContent", child3()); builder2.CloseComponent(); } if (EnableValidation) { builder2.OpenComponent <DataAnnotationsValidator>(0); builder2.CloseComponent(); } if (EnableValidationSummary && !IsInTableRow) { builder2.OpenComponent <ValidationSummary>(1); builder2.CloseComponent(); } if (FieldList.Any()) { foreach (var groupResult in GroupByRow(FieldList)) { Process(builder2, groupResult); } } else { if (!PreventDefaultRendering) { foreach (var groupResult in GroupByRow(ReflectionHelper.GetProperties(Model).Select(pi => GetField(pi)))) { // Console.WriteLine(property.PropertyType.FullName); Process(builder2, groupResult); } } } if (!IsInTableRow) { builder2.AddMarkupContent(27, $"<button form=\"{Id}\" type=\"submit\" style=\"display: none;\">Submit</button>\r\n"); } }; builder.OpenComponent <CascadingValue <EditContext> >(3); builder.AddAttribute(4, "IsFixed", true); builder.AddAttribute(5, "Value", mEditContext); builder.AddAttribute(6, "ChildContent", child(mEditContext)); builder.CloseComponent(); if (!IsInTableRow) { builder.CloseComponent(); //div } builder.CloseRegion(); }