private void BuildRendererTreeForInputs(BlazorRendererTreeBuilder rendererBuilder) { if (parser == TryParseDateTime || parser == TryParseDateTimeOffset) { rendererBuilder .OpenElement(HtmlTagNames.Input, "edit-text-field edit-date-field-filter") .AddAttribute(HtmlAttributes.Type, HtmlAttributes.TypeDate) .AddAttribute(HtmlAttributes.Value, BindMethods.GetValue(FormatDateAsString(actualFilterValue))) .AddAttribute(HtmlJSEvents.OnChange, BindMethods.SetValueHandler(delegate(string __value) { FilterValueChanged(__value); }, FormatDateAsString(actualFilterValue))) .CloseElement(); return; } rendererBuilder .OpenElement(HtmlTagNames.Input, "edit-text-field edit-text-field-filter") .AddAttribute(HtmlAttributes.Value, BindMethods.GetValue(filterIsApplied ? actualFilterValue.ToString() : string.Empty)) .AddAttribute(HtmlJSEvents.OnChange, BindMethods.SetValueHandler(delegate(string __value) { FilterValueChanged(__value); }, actualFilterValue?.ToString() ?? string.Empty)) .CloseElement(); }
private void BuildRendererTreeForInputs(BlazorRendererTreeBuilder rendererBuilder) { if (parser == TryParseDateTime || parser == TryParseDateTimeOffset) { _ = rendererBuilder .OpenElement(HtmlTagNames.Input, "edit-text-field edit-date-field-filter") .AddAttribute(HtmlAttributes.Type, HtmlAttributes.TypeDate) .AddAttribute(HtmlAttributes.Value, FormatDateAsString(actualFilterValue)) .AddAttribute(HtmlJSEvents.OnChange, EventCallback.Factory.Create(this, (ChangeEventArgs e) => { FilterValueChanged(BindConverterExtensions.ConvertTo(e.Value, string.Empty)); })) .CloseElement(); return; } rendererBuilder .OpenElement(HtmlTagNames.Input, "edit-text-field edit-text-field-filter") .AddAttribute(HtmlAttributes.Value, filterIsApplied ? actualFilterValue.ToString() : string.Empty) .AddAttribute(HtmlJSEvents.OnChange, EventCallback.Factory.Create(this, (ChangeEventArgs e) => { FilterValueChanged(BindConverterExtensions.ConvertTo(e.Value, string.Empty)); })) .CloseElement(); }
protected override void BuildRenderTree(RenderTreeBuilder builder) { base.BuildRenderTree(builder); LoadStateIfExists(); var rendererBuilder = new BlazorRendererTreeBuilder(builder); rendererBuilder .OpenElement(HtmlTagNames.Button, filterIsApplied ? "action-button action-button-small action-button-filter-active" : "action-button action-button-small") .AddAttribute(HtmlJSEvents.OnClick, EventCallback.Factory.Create(this, (MouseEventArgs e) => { filterDefinitionOpened = !filterDefinitionOpened; }) ) .OpenElement(HtmlTagNames.Span) .OpenElement(HtmlTagNames.I, "fas fa-filter") .CloseElement() .CloseElement() .CloseElement(); rendererBuilder.OpenElement(HtmlTagNames.Div, filterDefinitionOpened ? parser != TryParseBool ? $"{WrapperCssClass} {WrapperCssClass}-open" : $"{WrapperCssClass} {WrapperCssClass}-open {WrapperCssCheckboxClass}" : $"{WrapperCssClass}"); if (parser == TryParseBool) { BuildRendererTreeForCheckbox(rendererBuilder); } else { BuildRendererTreeForFilterOperations(rendererBuilder); BuildRendererTreeForInputs(rendererBuilder); } if (parser != TryParseBool) { rendererBuilder.OpenElement(HtmlTagNames.Div, "filter-buttons"); _ = rendererBuilder.OpenElement(HtmlTagNames.Button, "btn btn-light filter-buttons-clear") .AddAttribute(HtmlJSEvents.OnClick, EventCallback.Factory.Create(this, (MouseEventArgs e) => { ClearFilter(); }) ) .AddContent("Clear") .CloseElement() .CloseElement(); } rendererBuilder.CloseElement(); }
private RenderFragment CreateOptionsFragment(object value) { return(delegate(RenderTreeBuilder internalBuilder) { var rendererTreeBuilder = new BlazorRendererTreeBuilder(internalBuilder); if (value is Enum enumTypeValue) { foreach (var enumValue in Enum.GetValues(enumTypeValue.GetType())) { var enumStringValue = enumValue.ToString(); rendererTreeBuilder.OpenElement(HtmlTagNames.Option); if (enumStringValue == value.ToString()) { rendererTreeBuilder.AddAttribute(HtmlAttributes.Selected, true); } rendererTreeBuilder .AddAttribute(HtmlAttributes.Value, enumStringValue) .AddContent(enumStringValue) .CloseElement(); } } }); }
private void BuildRendererTreeForFilterOperations(BlazorRendererTreeBuilder rendererBuilder) { rendererBuilder .OpenElement(HtmlTagNames.Select) .AddAttribute(HtmlJSEvents.OnChange, EventCallback.Factory.Create(this, (ChangeEventArgs e) => { selectedFilterOperation = (FilterOperation)BindConverterExtensions.ConvertTo(e.Value, 1); if (filterIsApplied) { filterContext.AddOrUpdateFilterDefinition(new ExpressionFilterDefinition( ColumnName, selectedFilterOperation, actualFilterValue, TextComparison)); } })); foreach (var enumValue in Enum.GetValues(typeof(FilterOperation))) { var filterOperation = (FilterOperation)enumValue; if (!allowedFilterOperations.HasFlag(filterOperation) || filterOperation == FilterOperation.None) { continue; } selectedFilterOperation = selectedFilterOperation == FilterOperation.None ? filterOperation : selectedFilterOperation; var enumStringValue = enumValue.ToString(); rendererBuilder.OpenElement(HtmlTagNames.Option); if (enumStringValue == selectedFilterOperation.ToString()) { rendererBuilder.AddAttribute(HtmlAttributes.Selected, true); } rendererBuilder .AddAttribute(HtmlAttributes.Value, (int)enumValue) .AddContent(enumStringValue) .CloseElement(); } rendererBuilder.CloseElement(); }
private void BuildRendererTreeForFilterOperations(BlazorRendererTreeBuilder rendererBuilder) { rendererBuilder .OpenElement(HtmlTagNames.Select) .AddAttribute(HtmlJSEvents.OnChange, BindMethods.SetValueHandler(delegate(int __value) { selectedFilterOperation = (FilterOperation)__value; if (filterIsApplied) { filterContext.AddOrUpdateFilterDefinition(new ExpressionFilterDefinition(ColumnName, selectedFilterOperation, actualFilterValue)); } }, (int)selectedFilterOperation)); foreach (var enumValue in Enum.GetValues(typeof(FilterOperation))) { var filterOperation = (FilterOperation)enumValue; if (!allowedFilterOperations.HasFlag(filterOperation) || filterOperation == FilterOperation.None) { continue; } selectedFilterOperation = selectedFilterOperation == FilterOperation.None ? filterOperation : selectedFilterOperation; var enumStringValue = enumValue.ToString(); rendererBuilder.OpenElement(HtmlTagNames.Option); if (enumStringValue == selectedFilterOperation.ToString()) { rendererBuilder.AddAttribute(HtmlAttributes.Selected, true); } rendererBuilder .AddAttribute(HtmlAttributes.Value, (int)enumValue) .AddContent(enumStringValue) .CloseElement(); } rendererBuilder.CloseElement(); }
protected override void BuildRenderTree(RenderTreeBuilder builder) { base.BuildRenderTree(builder); var internalBuilder = new BlazorRendererTreeBuilder(builder); internalBuilder .OpenElement("div") .AddAttribute("id", Id) .AddAttribute("style", "display: none") .AddContent(ChildContent) .CloseElement(); }
protected override void BuildRenderTree(RenderTreeBuilder builder) { if (!CreateItemOptions.IsCreateItemAllowed || !PermissionContext.HasCreateItemPermission) { return; } base.BuildRenderTree(builder); var internalBuilder = new BlazorRendererTreeBuilder(builder); var createItemContext = new CreateItemContext(CreateItemOptions, CreateFormCssClasses); createItemContext.OnItemCreated += (object sender, ItemCreatedArgs e) => NewItemCreated?.Invoke(e); internalBuilder .OpenElement(HtmlTagNames.Div, "modal") .AddAttribute(HtmlAttributes.Id, CreateItemOptions.CreateItemModalName) .AddAttribute("role", "dialog") .OpenElement(HtmlTagNames.Div, $"modal-dialog modal-dialog-centered {CreateFormCssClasses.ModalSize}") .AddAttribute(HtmlAttributes.Id, CreateItemOptions.CreateItemModalSizeDiv) .OpenElement(HtmlTagNames.Div, "modal-content") .OpenElement(HtmlTagNames.Div, CreateFormCssClasses.ModalHeader) .OpenElement(HtmlTagNames.H4, "modal-title") .AddContent("Create Item") .CloseElement() .OpenElement(HtmlTagNames.Button, "close") .AddAttribute(HtmlJSEvents.OnClick, BindMethods.GetEventHandlerValue((UIMouseEventArgs e) => FlexGridInterop.HideModal(CreateItemOptions.CreateItemModalName))) .AddAttribute(HtmlAttributes.Type, "button") .AddAttribute("data-dismiss", "modal") .AddAttribute("aria-label", "Close") .OpenElement(HtmlTagNames.Span) .AddAttribute(HtmlAttributes.AriaHidden, "true") .AddContent(new MarkupString("×")) .CloseElement() .CloseElement() .CloseElement() .OpenElement(HtmlTagNames.Div, CreateFormCssClasses.ModalBody) .OpenComponent(typeof(CreateItemForm <,>) .MakeGenericType(CreateItemOptions.ModelType, CreateItemOptions.OutputDtoType)) .AddAttribute(nameof(CreateItemContext), createItemContext) .CloseComponent() .CloseElement() .CloseElement() .CloseElement() .CloseElement(); }
private void BuildRendererTreeForCheckbox(BlazorRendererTreeBuilder rendererBuilder) { rendererBuilder .OpenElement(HtmlTagNames.Label, "switch") .OpenElement(HtmlTagNames.Input) .AddAttribute(HtmlAttributes.Type, HtmlAttributes.Checkbox) .AddAttribute(HtmlAttributes.Value, BindMethods.GetValue(actualFilterValue)) .AddAttribute(HtmlJSEvents.OnChange, BindMethods.SetValueHandler(delegate(bool __value) { FilterBoolValueChanged(__value); }, (bool)(object)actualFilterValue)) .CloseElement() .OpenElement(HtmlTagNames.Span, "slider round") .CloseElement() .CloseElement(); }
private void BuildRendererTreeForCheckbox(BlazorRendererTreeBuilder rendererBuilder) { rendererBuilder .OpenElement(HtmlTagNames.Label, "switch") .OpenElement(HtmlTagNames.Input) .AddAttribute(HtmlAttributes.Type, HtmlAttributes.Checkbox) .AddAttribute(HtmlAttributes.Value, actualFilterValue) .AddAttribute(HtmlJSEvents.OnChange, EventCallback.Factory.Create(this, (ChangeEventArgs e) => { FilterBoolValueChanged(BindConverterExtensions.ConvertTo(e.Value, false)); })) .CloseElement() .OpenElement(HtmlTagNames.Span, "slider round") .CloseElement() .CloseElement(); }
public void Configure(EntityTypeBuilder <Order> builder) { builder.AllowInlineEdit(); builder.HasEmptyItemsMessage("<h1>Test</h1>", true); builder.IsMasterTable(); builder.HasDetailRelationship(o => o.OrderItems) .HasCaption("Order products"); RenderFragment <Order> statusFragment = o => delegate(RenderTreeBuilder rendererTreeBuilder) { var internalBuilder = new BlazorRendererTreeBuilder(rendererTreeBuilder); internalBuilder .OpenElement("div") .AddContent($"{o.Status}!!!") .CloseElement(); }; builder.Property(o => o.Status) .HasBlazorComponentValueRender(statusFragment); }
protected override void BuildRenderTree(RenderTreeBuilder builder) { base.BuildRenderTree(builder); var internalBuilder = new BlazorRendererTreeBuilder(builder); internalBuilder .OpenElement("div") .AddAttribute("style", $"width: {InitialMapOptions.Width}; height: {InitialMapOptions.Height}") .AddAttribute("id", Id) .AddAttribute("class", CssClasses) .OpenElement("script") .AddAttribute("async", "") .AddAttribute("defer", "") .AddAttribute("src", !string.IsNullOrEmpty(GoogleMapOptions.ApiKey) ? $"https://maps.googleapis.com/maps/api/js?key={GoogleMapOptions.ApiKey}&callback=blazorGoogleMap.initMapCallback" : string.Empty ) .CloseElement() .CloseElement(); }