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); } }
public override void RenderInput(GridRendererContext gridRendererContext) { var localColumnName = gridRendererContext.ActualColumnName; var value = gridRendererContext.PropertyValueAccessor.GetValue(gridRendererContext.ActualItem, 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"; gridRendererContext.OpenElement(HtmlTagNames.Div, "edit-field-wrapper"); gridRendererContext.OpenElement(HtmlTagNames.Input, "edit-text-field"); gridRendererContext.AddAttribute(HtmlAttributes.Type, dateValueContatinsTime ? "datetime-local" : "date"); gridRendererContext.AddAttribute(HtmlAttributes.Value, BindMethods.GetValue(dateTimeValue, dateFormat)); gridRendererContext.AddAttribute(HtmlJSEvents.OnChange, BindMethods.SetValueHandler(delegate(DateTime __value) { gridRendererContext .TableDataSet .EditItemProperty(localColumnName, __value); }, dateTimeValue, dateFormat) ); gridRendererContext.CloseElement(); gridRendererContext.CloseElement(); } else { successor.RenderInput(gridRendererContext); } }
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(); }
/// <inheritdoc /> protected override void BuildRenderTree(RenderTreeBuilder builder) { builder.OpenElement(0, "textarea"); builder.AddAttribute(1, "id", Id); builder.AddAttribute(2, "class", CssClass); builder.AddAttribute(3, "value", BindMethods.GetValue(CurrentValue)); builder.AddAttribute(4, "onchange", BindMethods.SetValueHandler(__value => CurrentValue = __value, CurrentValue)); builder.CloseElement(); }
/// <inheritdoc /> protected override void BuildRenderTree(RenderTreeBuilder builder) { builder.OpenElement(0, "input"); builder.AddAttribute(1, "type", "number"); builder.AddAttribute(2, "step", _stepAttributeValue); builder.AddAttribute(3, "id", Id); builder.AddAttribute(4, "class", CssClass); builder.AddAttribute(5, "value", BindMethods.GetValue(CurrentValueAsString)); builder.AddAttribute(6, "onchange", BindMethods.SetValueHandler(__value => CurrentValueAsString = __value, CurrentValueAsString)); builder.CloseElement(); }
/// <inheritdoc /> protected override void BuildRenderTree(RenderTreeBuilder builder) { base.BuildRenderTree(builder); builder.OpenElement(0, "select"); builder.AddAttribute(1, "id", Id); builder.AddAttribute(2, "class", CssClass); builder.AddAttribute(3, "value", BindMethods.GetValue(CurrentValueAsString)); builder.AddAttribute(4, "onchange", BindMethods.SetValueHandler(__value => CurrentValueAsString = __value, CurrentValueAsString)); builder.AddContent(5, ChildContent); builder.CloseElement(); }
/// <inheritdoc /> protected override void BuildRenderTree(RenderTreeBuilder builder) { builder.OpenElement(0, "input"); builder.AddMultipleAttributes(1, AdditionalAttributes); builder.AddAttribute(2, "type", "checkbox"); builder.AddAttribute(3, "id", Id); builder.AddAttribute(4, "class", CssClass); builder.AddAttribute(5, "checked", BindMethods.GetValue(CurrentValue)); builder.AddAttribute(6, "onchange", BindMethods.SetValueHandler(__value => CurrentValue = __value, CurrentValue)); builder.CloseElement(); }
private void AddDoubleValueHandlerIfValueIsDouble(IRendererTreeBuilder rendererTreeBuilder, Action <string, object> onChangeAction, string localColumnName, object value) { if (value is double doubleValue) { rendererTreeBuilder.AddAttribute(HtmlJSEvents.OnChange, BindMethods.SetValueHandler(delegate(double __value) { onChangeAction?.Invoke(localColumnName, __value); }, doubleValue) ); } }
protected override void BuildRenderTree(RenderTreeBuilder builder) { builder.OpenElement(0, "input"); builder.AddAttribute(1, "type", "checkbox"); builder.AddAttribute(2, "value", BindMethods.GetValue(CheckboxEnabled)); builder.AddAttribute(3, "onchange", BindMethods.SetValueHandler(__value => CheckboxEnabled = __value, CheckboxEnabled)); builder.CloseElement(); builder.OpenElement(4, "input"); builder.AddAttribute(5, "value", BindMethods.GetValue(SomeStringProperty)); builder.AddAttribute(6, "onchange", BindMethods.SetValueHandler(__value => SomeStringProperty = __value, SomeStringProperty)); builder.AddAttribute(7, "disabled", !CheckboxEnabled); builder.CloseElement(); }
private void AddDoubleValueHandlerIfValueIsDouble(GridRendererContext gridRendererContext, string localColumnName, object value) { if (value is double doubleValue) { gridRendererContext.AddAttribute(HtmlJSEvents.OnChange, BindMethods.SetValueHandler(delegate(double __value) { gridRendererContext .TableDataSet .EditItemProperty(localColumnName, __value); }, doubleValue) ); } }
private void AddLongValueHandlerIfValueIsLong(IRendererTreeBuilder rendererTreeBuilder, Action <string, object> onChangeAction, string localColumnName, object value) { if (value is long longValue) { rendererTreeBuilder.AddAttribute(HtmlJSEvents.OnChange, BindMethods.SetValueHandler(delegate(long __value) { onChangeAction?.Invoke(localColumnName, __value); }, longValue) ); } else { AddDecimalValueHandlerIfValueIsDecimal(rendererTreeBuilder, onChangeAction, localColumnName, value); } }
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 AddLongValueHandlerIfValueIsLong(GridRendererContext gridRendererContext, string localColumnName, object value) { if (value is long longValue) { gridRendererContext.AddAttribute(HtmlJSEvents.OnChange, BindMethods.SetValueHandler(delegate(long __value) { gridRendererContext .TableDataSet .EditItemProperty(localColumnName, __value); }, longValue) ); } else { AddDecimalValueHandlerIfValueIsDecimal(gridRendererContext, localColumnName, value); } }
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, BindMethods.SetValueHandler(delegate(string __value) { var parsedValue = Enum.Parse(value.GetType(), __value); onChangeAction?.Invoke(localColumnName, parsedValue); }, value?.ToString() ?? string.Empty) ); 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); } }
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(); }
public override void RenderInput(GridRendererContext gridRendererContext) { var localColumnName = gridRendererContext.ActualColumnName; var value = gridRendererContext.PropertyValueAccessor.GetValue(gridRendererContext.ActualItem, localColumnName); if (value is Enum enumTypeValue) { var actualStringValue = enumTypeValue.ToString(); gridRendererContext.OpenElement(HtmlTagNames.Div, "edit-field-wrapper"); gridRendererContext.OpenElement(HtmlTagNames.Select, "edit-text-field"); gridRendererContext.AddAttribute(HtmlJSEvents.OnChange, BindMethods.SetValueHandler(delegate(string __value) { var parsedValue = Enum.Parse(value.GetType(), __value); gridRendererContext .TableDataSet .EditItemProperty(localColumnName, parsedValue); }, value.ToString()) ); foreach (var enumValue in Enum.GetValues(enumTypeValue.GetType())) { var enumStringValue = enumValue.ToString(); gridRendererContext.OpenElement(HtmlTagNames.Option); if (enumStringValue == actualStringValue) { gridRendererContext.AddAttribute(HtmlAttributes.Selected, true); } gridRendererContext.AddAttribute(HtmlAttributes.Value, enumStringValue); gridRendererContext.AddContent(enumStringValue); gridRendererContext.CloseElement(); } gridRendererContext.CloseElement(); gridRendererContext.CloseElement(); } else { successor.RenderInput(gridRendererContext); } }
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(); }
public override void RenderInput(GridRendererContext gridRendererContext) { var localColumnName = gridRendererContext.ActualColumnName; var value = gridRendererContext.PropertyValueAccessor.GetValue(gridRendererContext.ActualItem, gridRendererContext.ActualColumnName); gridRendererContext.OpenElement(HtmlTagNames.Div, "edit-field-wrapper"); gridRendererContext.OpenElement(HtmlTagNames.Input, "edit-text-field"); gridRendererContext.AddAttribute(HtmlAttributes.Type, GetInputType(value.ToString())); gridRendererContext.AddAttribute(HtmlAttributes.Value, BindMethods.GetValue(value)); gridRendererContext.AddAttribute(HtmlJSEvents.OnChange, BindMethods.SetValueHandler(delegate(string __value) { gridRendererContext .TableDataSet .EditItemProperty(localColumnName, __value); }, value.ToString()) ); gridRendererContext.CloseElement(); gridRendererContext.CloseElement(); }