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);
            }
        }
        public override void BuildInputRendererTree(IRendererTreeBuilder rendererTreeBuilder, IActualItemContext <object> actualItemContext, Action <string, object> onChangeAction)
        {
            var localColumnName = actualItemContext.ActualColumnName;
            var value           = actualItemContext.GetActualItemColumnValue(localColumnName);

            if (IsSupportedDateType(value))
            {
                var dateTimeValue          = ConvertToDateTime(value);
                var dateValueContatinsTime = dateTimeValue.TimeOfDay.TotalSeconds != 0;
                var dateFormat             = dateValueContatinsTime ? "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, dateValueContatinsTime ? "datetime-local" : "date")
                .AddAttribute(HtmlAttributes.Value, BindMethods.GetValue(dateTimeValue, dateFormat))
                .AddAttribute(HtmlJSEvents.OnChange, BindMethods.SetValueHandler(delegate(DateTime __value)
                {
                    onChangeAction?.Invoke(localColumnName, __value);
                }, dateTimeValue, dateFormat))
                .CloseElement()
                .CloseElement();
            }
            else
            {
                successor.BuildInputRendererTree(rendererTreeBuilder, actualItemContext, onChangeAction);
            }
        }
예제 #3
0
        public static IRendererTreeBuilder OpenElement(this IRendererTreeBuilder rendererTreeBuilder, string elementName, string className)
        {
            rendererTreeBuilder
            .OpenElement(elementName)
            .AddCssClass(className);

            return(rendererTreeBuilder);
        }
예제 #4
0
        public override void BuildInputRendererTree(IRendererTreeBuilder rendererTreeBuilder, IActualItemContext <object> actualItemContext, Action <string, object> onChangeAction)
        {
            var localColumnName = actualItemContext.ActualColumnName;
            var value           = actualItemContext.GetActualItemColumnValue(localColumnName);

            if (value is Enum enumTypeValue)
            {
                var actualStringValue = enumTypeValue.ToString();

                rendererTreeBuilder
                .OpenElement(HtmlTagNames.Div, "edit-field-wrapper")
                .OpenElement(HtmlTagNames.Select, "edit-text-field")
                .AddAttribute(HtmlJSEvents.OnChange, EventCallback.Factory.Create(this,
                                                                                  (ChangeEventArgs e) =>
                {
                    var parsedValue = Enum.Parse(value.GetType(), e.Value.ToString());
                    onChangeAction?.Invoke(localColumnName, parsedValue);
                }
                                                                                  ));

                foreach (var enumValue in Enum.GetValues(enumTypeValue.GetType()))
                {
                    var enumStringValue = enumValue.ToString();

                    rendererTreeBuilder.OpenElement(HtmlTagNames.Option);
                    if (enumStringValue == actualStringValue)
                    {
                        rendererTreeBuilder.AddAttribute(HtmlAttributes.Selected, true);
                    }

                    rendererTreeBuilder
                    .AddAttribute(HtmlAttributes.Value, enumStringValue)
                    .AddContent(enumStringValue)
                    .CloseElement();
                }

                rendererTreeBuilder
                .CloseElement()
                .CloseElement();
            }
            else
            {
                successor.BuildInputRendererTree(rendererTreeBuilder, actualItemContext, onChangeAction);
            }
        }
예제 #5
0
        public void BuildRendererTree(
            ICreateFormLayout <TItem> createFormLayout,
            CreateItemRendererContext <TItem> createItemRendererContext,
            IRendererTreeBuilder rendererTreeBuilder)
        {
            var bodyAction   = createFormLayout.BuildBodyRendererTree(createItemRendererContext, editInputRendererTree);
            var footerAction = createFormLayout.BuildFooterRendererTree(createItemRendererContext);

            rendererTreeBuilder.OpenElement(HtmlTagNames.Form);

            bodyAction?.Invoke(rendererTreeBuilder);
            footerAction?.Invoke(rendererTreeBuilder);

            rendererTreeBuilder.CloseElement();
        }
        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();
        }
        public override void BuildInputRendererTree(IRendererTreeBuilder rendererTreeBuilder, IActualItemContext <object> actualItemContext, Action <string, object> onChangeAction)
        {
            var localColumnName = actualItemContext.ActualColumnName;
            var value           = actualItemContext.GetActualItemColumnValue(localColumnName);

            rendererTreeBuilder
            .OpenElement(HtmlTagNames.Div, "edit-field-wrapper")
            .OpenElement(HtmlTagNames.Input, "edit-text-field")
            .AddAttribute(HtmlAttributes.Type, GetInputType(value?.ToString() ?? InputTypeText))
            .AddAttribute(HtmlAttributes.Value, BindMethods.GetValue(value))
            .AddAttribute(HtmlJSEvents.OnChange,
                          BindMethods.SetValueHandler(delegate(string __value)
            {
                onChangeAction?.Invoke(localColumnName, __value);
            }, value?.ToString() ?? string.Empty)
                          )
            .CloseElement()
            .CloseElement();
        }
예제 #8
0
        public override void BuildInputRendererTree(IRendererTreeBuilder rendererTreeBuilder, IActualItemContext <object> actualItemContext, Action <string, object> onChangeAction, string columnName)
        {
            var value = actualItemContext.GetActualItemColumnValue(columnName);

            if (IsSupportedNumberType(value))
            {
                rendererTreeBuilder
                .OpenElement(HtmlTagNames.Div, "edit-field-wrapper")
                .OpenElement(HtmlTagNames.Input, "edit-text-field")
                .AddAttribute(HtmlAttributes.Type, "number");

                TryAddOnChangeHandler(rendererTreeBuilder, onChangeAction, columnName, value);

                rendererTreeBuilder
                .CloseElement()
                .CloseElement();
            }
            else
            {
                Successor.BuildInputRendererTree(rendererTreeBuilder, actualItemContext, onChangeAction, columnName);
            }
        }