Beispiel #1
0
        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();
        }
Beispiel #3
0
        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();
        }