Exemplo n.º 1
0
        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();
        }
Exemplo n.º 2
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();
        }