public override void BuildInputRendererTree(IRendererTreeBuilder rendererTreeBuilder, IActualItemContext <object> actualItemContext, Action <string, object> onChangeAction, string columnName)
        {
            var value = actualItemContext.GetActualItemColumnValue(columnName);

            if (IsSupportedDateType(value))
            {
                var dateTimeValue         = ConvertToDateTime(value);
                var dateValueContainsTime = Math.Abs(dateTimeValue.TimeOfDay.TotalSeconds) > 0.00000000001;
                var dateFormat            = dateValueContainsTime ? "yyyy-MM-dd'T'HH:mm:ss" : "yyyy-MM-dd";

                rendererTreeBuilder
                .OpenElement(HtmlTagNames.Div, "edit-field-wrapper")
                .OpenElement(HtmlTagNames.Input, "edit-text-field")
                .AddAttribute(HtmlAttributes.Type, dateValueContainsTime ? "datetime-local" : "date")
                .AddAttribute(HtmlAttributes.Value, BindConverter.FormatValue(dateTimeValue, dateFormat))
                .AddAttribute(HtmlJsEvents.OnChange, EventCallback.Factory.Create(this,
                                                                                  (ChangeEventArgs e) =>
                {
                    onChangeAction?.Invoke(columnName, BindConverterExtensions.ConvertTo(e.Value, DateTime.MinValue));
                }))
                .CloseElement()
                .CloseElement();
            }
            else
            {
                Successor.BuildInputRendererTree(rendererTreeBuilder, actualItemContext, onChangeAction, columnName);
            }
        }
Esempio n. 2
0
        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();
        }
Esempio n. 3
0
        private void RenderGroupingFooterPart(GridRendererContext rendererContext)
        {
            rendererContext.OpenElement(HtmlTagNames.Div, rendererContext.CssClasses.FooterCssClasses.GroupingPartWrapper);
            rendererContext.OpenElement(HtmlTagNames.Select, "group-select");
            rendererContext.AddAttribute(HtmlAttributes.Id, GroupingSelectId);
            rendererContext.AddAttribute(HtmlJsEvents.OnChange,
                                         EventCallback.Factory.Create(this, async(ChangeEventArgs e) =>
            {
                rendererContext.TableDataSet.GroupingOptions.SetGroupedProperty(BindConverterExtensions.ConvertTo(e.Value, string.Empty));
                await rendererContext.TableDataSet.GoToPage(0);
                rendererContext.RequestRerenderNotification?.Invoke();
            })
                                         );

            if (!rendererContext.TableDataSet.GroupingOptions.IsGroupingActive)
            {
                rendererContext.OpenElement(HtmlTagNames.Option);
                rendererContext.AddAttribute(HtmlAttributes.Disabled, true);
                rendererContext.AddContent(GroupByPlaceholder);
                rendererContext.CloseElement();
            }

            foreach (var groupableProperty in rendererContext.TableDataSet.GroupingOptions.GroupableProperties)
            {
                rendererContext.OpenElement(HtmlTagNames.Option);

                if (groupableProperty == rendererContext.TableDataSet.GroupingOptions.GroupedProperty)
                {
                    rendererContext.AddAttribute(HtmlAttributes.Selected, true);
                }

                rendererContext.AddAttribute(HtmlAttributes.Value, groupableProperty.Name);
                rendererContext.AddContent(rendererContext.GetColumnCaption(groupableProperty.Name) ?? groupableProperty.Name);
                rendererContext.CloseElement();
            }

            rendererContext.CloseElement();
            rendererContext.CloseElement();

            if (rendererContext.TableDataSet.GroupingOptions.IsGroupingActive)
            {
                rendererContext.OpenElement(HtmlTagNames.Button, "action-button");
                rendererContext.AddOnClickEvent(
                    EventCallback.Factory.Create(this, (MouseEventArgs e) =>
                {
                    rendererContext.TableDataSet.GroupingOptions.DeactivateGrouping();
                    rendererContext.RequestRerenderNotification?.Invoke();
                })
                    );

                rendererContext.OpenElement(HtmlTagNames.Span, "action-button-span");
                rendererContext.OpenElement(HtmlTagNames.I, "fas fa-times");
                rendererContext.CloseElement();
                rendererContext.CloseElement();
                rendererContext.CloseElement();
            }
        }
Esempio n. 4
0
 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();
 }
Esempio n. 5
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();
        }
Esempio n. 6
0
 private void AddDoubleValueHandlerIfValueIsDouble(IRendererTreeBuilder rendererTreeBuilder, Action <string, object> onChangeAction, string localColumnName, object value)
 {
     if (value is double doubleValue)
     {
         rendererTreeBuilder.AddAttribute(HtmlAttributes.Value, BindConverter.FormatValue(doubleValue));
         rendererTreeBuilder.AddAttribute(HtmlJSEvents.OnChange, EventCallback.Factory.Create(this,
                                                                                              (ChangeEventArgs e) => onChangeAction?.Invoke(localColumnName, BindConverterExtensions.ConvertTo(e.Value, 0d))));
     }
 }
Esempio n. 7
0
 private void TryAddOnChangeHandler(IRendererTreeBuilder rendererTreeBuilder, Action <string, object> onChangeAction, string localColumnName, object value)
 {
     if (value is int intValue)
     {
         rendererTreeBuilder.AddAttribute(HtmlAttributes.Value, BindConverter.FormatValue(intValue));
         rendererTreeBuilder.AddAttribute(HtmlJSEvents.OnChange, EventCallback.Factory.Create(this,
                                                                                              (ChangeEventArgs e) => onChangeAction?.Invoke(localColumnName, BindConverterExtensions.ConvertTo(e.Value, 0))));
     }
     else
     {
         AddLongValueHandlerIfValueIsLong(rendererTreeBuilder, onChangeAction, localColumnName, value);
     }
 }
        public override void BuildInputRendererTree(IRendererTreeBuilder rendererTreeBuilder, IActualItemContext <object> actualItemContext, Action <string, object> onChangeAction, string columnName)
        {
            var value = actualItemContext.GetActualItemColumnValue(columnName);

            rendererTreeBuilder
            .OpenElement(HtmlTagNames.Div, "edit-field-wrapper")
            .OpenElement(HtmlTagNames.Input, "edit-text-field")
            .AddAttribute(HtmlAttributes.Type, GetInputType(value?.ToString() ?? InputTypeText))
            .AddAttribute(HtmlAttributes.Value, BindConverter.FormatValue(value))
            .AddAttribute(HtmlJsEvents.OnChange, EventCallback.Factory.Create(this,
                                                                              (ChangeEventArgs e) => onChangeAction?.Invoke(columnName, BindConverterExtensions.ConvertTo(e.Value, string.Empty)))
                          )
            .CloseElement()
            .CloseElement();
        }