Table of Contents

Class EditScreenInjector<TScreen, TModel>

Namespace
Dynamicweb.CoreUI.Screens
Assembly
Dynamicweb.CoreUI.dll

Base class for injecting groups, editors, and actions into an EditScreenBase<TModel> without modifying the screen class itself. Implementations are discovered automatically via AddInManager — no DI registration required.

public abstract class EditScreenInjector<TScreen, TModel> : ScreenInjector<TScreen> where TScreen : EditScreenBase<TModel>, new() where TModel : DataViewModelBase, new()

Type Parameters

TScreen

The edit screen type to inject into.

TModel

The data model type used by the screen.

Inheritance
EditScreenInjector<TScreen, TModel>
Derived
Inherited Members

Remarks

Example — all three extension points on PriceEditScreen:

using System.Collections.Generic;
using Dynamicweb.CoreUI.Actions;
using Dynamicweb.CoreUI.Editors;
using Dynamicweb.CoreUI.Editors.Inputs;
using Dynamicweb.CoreUI.Screens;
using Dynamicweb.Products.UI.Models.Prices;
using Dynamicweb.Products.UI.Screens.Prices;

public sealed class PriceEditScreenInjector : EditScreenInjector<PriceEditScreen, PriceDataModel>
{
    // 1. Add groups to an existing tab, or pass a new tab name to create one.
    //
    //    EditorFor() binds to a model property and resolves an editor via the screen's own GetEditor().
    //    To display data that does not exist on the model, construct an editor manually and set its
    //    Label and Value directly — then add it alongside the model-bound editors.
    public override void OnBuildEditScreen(EditScreenBase<PriceDataModel>.EditScreenBuilder builder)
    {
        // Model-bound fields:
        builder.AddComponents("General", "Pricing", new[]
        {
            builder.EditorFor(m => m.Priority),
            builder.EditorFor(m => m.IsInformative),
        });

        // External data — not on the model, fetched from elsewhere:
        var productId = Screen?.Model?.ProductId;
        var externalInfo = productId is not null
            ? MyService.GetSomeInfo(productId)
            : null;

        builder.AddComponents("General", "External info", new[]
        {
            new Text { Label = "Some info", Value = externalInfo?.Name, Readonly = true },
            new Text { Label = "Status",    Value = externalInfo?.Status, Readonly = true },
        });
    }

    // 2. Supply a custom editor for a model-bound property.
    //    Return null to fall back to the screen's own editor resolution.
    public override EditorBase? GetEditor(string propertyName, PriceDataModel? model) => propertyName switch
    {
        nameof(PriceDataModel.Priority) => new Number { Min = 0, Max = 100 },
        _ => null,
    };

    // 3. Add toolbar buttons to the screen.
    public override IEnumerable<ActionGroup>? GetScreenActions() =>
    [
        new() { Nodes = [ new MyCustomAction() ] }
    ];
}

Methods

GetEditor(string, TModel?)

Override to supply a custom editor for a model property. Return null to fall back to the screen's own editor resolution.

public virtual EditorBase? GetEditor(string propertyName, TModel? model)

Parameters

propertyName string
model TModel

Returns

EditorBase

GetScreenActions()

Override to add screen-level action groups (toolbar buttons, etc.).

public virtual IEnumerable<ActionGroup>? GetScreenActions()

Returns

IEnumerable<ActionGroup>

OnBuildEditScreen(EditScreenBuilder)

Override to add or modify groups and editors on the screen. Called after the screen's own BuildEditScreen method completes.

public virtual void OnBuildEditScreen(EditScreenBase<TModel>.EditScreenBuilder builder)

Parameters

builder EditScreenBase<TModel>.EditScreenBuilder

Builder for the target screen; use AddComponents and EditorFor.

To top