Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
A list of known limitations and issues in Umbraco UI Builder
Umbraco UI Builder strives to closely mimic the content pipeline while adhering to public and supported APIs. This ensures full compatibility with the Data Type suite for property editing. However, some features in the Umbraco Core rely on internal methods, making full support for certain functionalities challenging. Below is a list of known issues.
While Umbraco UI Builder supports persisting tag values, it currently does not write these tags to the cmsTags
database table. This functionality is managed by the internal tagsRepository
, which is not publicly accessible, preventing direct saving in the same manner as Umbraco Core.
Block Editors (Block List/Block Grid) are not currently supported due to casting errors between the JSON string representation and collection property.
An implementation to address this is investigated and will be scheduled for a future major release.
A guide to using Umbraco UI Builder for creating custom backoffice UIs.
Umbraco UI Builder is a tool for creating custom Backoffice User Interfaces (UIs) in Umbraco using a fluent API.
If you have a custom data store that you want to manage within Umbraco, you can use Umbraco UI Builder. With few lines of code, you can configure a custom administration UI, and reuse many core components with a consistent look and feel.
With Umbraco UI Builder, custom backoffice integrations can now be set up in minutes rather than days.
This documentation is intended for developers with a basic understanding of Umbraco and C#/MVC principles.
If you are new to Umbraco UI Builder, it is recommended to start with the Getting Started section. This section covers system requirements and installation instructions.
Once you have Umbraco UI Builder installed, explore the Guides section. This section provides a quick-start example on configuring Umbraco UI Builder.
Use the main menu to explore features in detail and navigate directly to topics of interest.
For additional resources and best practices, visit the Miscellaneous section.
If you need assistance, refer to our support channels for help and troubleshooting.
Configure search functionality in Umbraco UI Builder.
Umbraco UI Builder includes a search API for filtering and locating specific entities within a collection. This enhances usability, especially in collections with large datasets.
Get started by reviewing how to define searchable properties.
Learn how to configure Umbraco UI Builder in your project using two different approaches.
You can configure Umbraco UI Builder either via a Composer or in the Program.cs
.
A Composer is a common approach for registering and configuring services in Umbraco during application startup.
To configure Umbraco UI Builder via a Composer:
Create a file called UIBuilderComposer.cs
in your project.
Implement the IComposer
interface and add the configuration inside the Compose
method:
Program.cs
You can also configure Umbraco UI Builder directly in Program.cs
using the AddUIBuilder
extension method.
To configure Umbraco UI Builder:
Open the Program.cs
file in your project.
Locate the CreateUmbracoBuilder()
method.
Add AddUIBuilder
before AddComposers()
.
For a complete sample configuration, see the article.
The AddUIBuilder
method accepts a delegate function, allowing you to configure your solution using fluent APIs.
Available property editors in Umbraco UI Builder for managing data in Umbraco content nodes.
Umbraco UI Builder provides property editors for managing data inside Umbraco content nodes.
The available property editors are:
using Umbraco.Cms.Core.Composing;
using Umbraco.UIBuilder.Extensions;
public class UIBuilderComposer : IComposer
{
public void Compose(IUmbracoBuilder builder)
{
builder.AddUIBuilder(cfg =>
{
// Apply your configuration here
});
}
}
builder.CreateUmbracoBuilder()
.AddBackOffice()
.AddWebsite()
.AddUIBuilder(cfg => {
// Apply your configuration here
})
.AddDeliveryApi()
.AddComposers()
.Build();
Learn how to manually upgrade Umbraco UI Builder to the latest version.
This article explains how to manually upgrade Umbraco UI Builder to the latest version. Before upgrading Umbraco UI Builder, see the Version Specific Upgrade Notes for potential breaking changes and common pitfalls.
Before upgrading, take a complete backup of your site and database.
To get the latest version of Umbraco UI Builder, you can upgrade using either of the two options:
To install the latest version via NuGet:
dotnet add package Umbraco.UIBuilder
To specify a package version:
dotnet add package Umbraco.UIBuilder --version <VERSION>
After adding the package reference, restore dependencies:
dotnet restore
Open Visual Studio.
Navigate to Tools
-> NuGet Package Manager
-> Manage NuGet Packages for Solution...
.
Select Umbraco.UIBuilder.
Choose the latest version from the drop-down and click Install.
After installation, verify the update in your .csproj file:
<ItemGroup>
<PackageReference Include="Umbraco.UIBuilder" Version="xx.x.x" />
</ItemGroup>
If you are using any of the following sub-packages, upgrade them as well:
Umbraco.UIBuilder.Core
Core functionality without infrastructure dependencies
Umbraco.UIBuilder.Infrastructure
Infrastructure-specific implementations
Umbraco.UIBuilder.Web
Core logic requiring a web context
Umbraco.UIBuilder.Web.StaticAssets
Static assets for the presentation layer
Umbraco.UIBuilder.Startup
Registers UI Builder with Umbraco
Umbraco.UIBuilder
The main UI Builder package
Version specific documentation for upgrading to major versions of Umbraco UI Builder.
This article provides upgrade instructions for major versions of Umbraco UI Builder.
Version 14 introduces breaking changes from the previous Konstrukt product. For full migration details, see the Migrate from Konstrukt to Umbraco UI Builder article.
For out-of-support versions, see the Legacy documentation on GitHub.
Configuring and using encrypted properties in Umbraco UI Builder to securely store sensitive data.
Umbraco UI Builder allows encrypting properties to store sensitive information securely. When a property is marked as encrypted, its value is automatically encrypted before storage and decrypted upon retrieval.
AddEncryptedProperty()
MethodEncrypts the specified property. The property must be of type String
. The value is encrypted before storage and decrypted when retrieved.
AddEncryptedProperty(Lambda encryptedPropertyExpression) : CollectionConfigBuilder<TEntityType>
collectionConfig.AddEncryptedProperty(p => p.Secret);
Configuring Field Views in Umbraco UI Builder.
Field Views allow customization of the markup used by a field when displayed in a list view. Field Views are implemented as .NET Core View Components, which are passed a FieldViewsContext
argument containing information about the entity/field being rendered.
You can define a field view in one of two ways:
FieldView
View ComponentFor field views, place a view file in the /Views/Shared/Components/FieldView
folder with the following markup.
@model Umbraco.UIBuilder.Web.Models.FieldViewContext
<!-- Insert your markup here -->
WTo register the view, pass the name of the view file (excluding the .cshtml
file extension) to the relevant API method.
For more complex field views, create a custom view component class that can use dependency injection for any required dependencies. Use the following signature:
// Example
public class MyComplexFieldViewViewComponent : ViewComponent
{
public async Task<IViewComponentResult> InvokeAsync(FieldViewContext context)
{
// Do your custom logic here
return View("Default", model);
}
}
For the view component, place a Default.cshtml
file into the /Views/Shared/Components/MyComplexFieldView
folder with the following markup:
@model Namespace.Of.Model.Returned.By.Custom.ViewComponent
<!-- Insert your markup here -->
Field view components are passed a FieldViewContext
object with the following properties:
public class FieldViewContext
{
public string ViewName { get; set; }
public object Entity { get; set; }
public string PropertyName { get; set; }
public object PropertyValue { get; set; }
}
A field view is assigned to a list view field as part of the list view configuration. For more information, see the List Views article.
Learn how to configure a global filter in Umbraco UI Builder.
Use global filters to work with a specific subset of data within a collection. These filters apply to all queries for a given collection.
Configure global filters in the Collections settings.
SetFilter()
MethodDefines a filter using a where clause expression. The expression must return a boolean
value.
SetFilter(Lambda whereClauseExpression) : CollectionConfigBuilder<TEntityType>
collectionConfig.SetFilter(p => p.Current);
A list of inbuilt actions that come with Umbraco UI Builder.
Umbraco UI Builder provides different inbuilt actions that you can use right away.
Namespace: Umbraco.UIBuilder.Infrastructure.Configuration.Actions
Exports entity data to a Comma-Separated Values (CSV) file. It converts all properties into column headings and renders each entity's property values in rows.
Namespace: Umbraco.UIBuilder.Infrastructure.Configuration.Actions
Imports data from a Comma-Separated Values (CSV) file. This action matches column headings with entity properties and maps row values to an entity.
Guidelines for fluent configuration and naming conventions in Umbraco UI Builder.
Umbraco UI Builder follows a fluent configuration style, allowing method chaining for concise and readable code. Alternatively, a lambda expression can be used for a more structured approach.
config.AddSection("Repositories")
.Tree()
.AddCollection<People>(p => p.Id, "Person", "People");
config.AddSection("Repositories", sectionConfig => {
sectionConfig.Tree(treeConfig => {
treeConfig.AddCollection<People>(p => p.Id, "Person", "People");
});
});
Methods prefixed with Add allow multiple configurations.
Methods prefixed with Set permit only one instance within the current configuration context.
Configuring a summary dashboard to provide an overview of collections within a section.
A summary dashboard appears automatically at the root of an Umbraco UI Builder section. It provides an overview of key collections within that section, enabling quick access to list views. Additionally, it allows for adding new entries to the collection, provided the collection is not set to read-only.
By summarizing important data and simplifying navigation, the summary dashboard improves content management efficiency.
To display a collection on the summary dashboard, use the ShowOnSummaryDashboard()
method in the collection configuration.
collectionConfig.ShowOnSummaryDashboard();
Code Reference: ShowOnSummaryDashboard() : CollectionConfigBuilder<TEntityType>
Only root-level collections within a section can be displayed on the summary dashboard.
Configuring collection in Umbraco UI Builder to manage entity groups and define their UI integration.
A collection in Umbraco UI Builder represents a group of entities for a specific data model. It serves as the primary configuration object for defining how the collection integrates into the UI.
You can configure its list view appearance and editing options.
Get started by reviewing the basics of collection configuration.
Learn how to configure cards in Umbraco UI Builder.
Cards provide an API to display summary information in a card-based format, which is useful for displaying key metrics about a collection.
Cards can be defined in two ways:
Configuring child collections in Umbraco UI Builder.
This page is a work in progress and may undergo further revisions, updates, or amendments. The information contained herein is subject to change without notice.
A child collection is a container for data models that are tied to a parent collection. The child collection system shares the Collections API, offering flexibility for managing and displaying related data within your backoffice UI.
By default, child collections are displayed as context apps within the parent model's editor view. If multiple child collections lead to an overcrowded context apps area, consider using the Child Collection Groups API. Using the API, you can group related child collections under a single context app, with each child collection appearing in separate tabs.
To define a child collection, use the AddChildCollection
method on the given collection config builder instance.
AddChildCollection()
MethodThis method adds a child collection with the specified names, description, and default icons. Both the entity ID and foreign key fields must be specified using property accessor expressions.
AddChildCollection<TChildEntityType>(Lambda idFieldExpression, Lambda fkFieldExpression, string nameSingular, string namePlural, string description, Lambda childCollectionConfig = null) : ChildCollectionConfigBuilder<TEntityType>
collectionConfig.AddChildCollection<Child>(c => c.Id, c => c.ParentId, "Child", "Children", "A collection of children", childCollectionConfig => {
...
});
AddChildCollection()
Method with Custom IconsThis method adds a child collection to the current collection with the specified names, description and custom icons. Both the entity ID and foreign key fields must be specified using property accessor expressions.
AddChildCollection<TChildEntityType>(Lambda idFieldExpression, Lambda fkFieldExpression, string nameSingular, string namePlural, string description, string iconSingular, string iconPlural, Lambda childCollectionConfig = null) : ChildCollectionConfigBuilder<TEntityType>
collectionConfig.AddChildCollection<Child>(c => c.Id, c => c.ParentId, "Child", "Children", "A collection of children", "icon-umb-users", "icon-umb-users", childCollectionConfig => {
...
});
Child collections share the same API as the Collection
config builder API, except child collections cannot contain further child collections. For more information, see the Basics article.
Learn how to configure data views in Umbraco UI Builder.
Data views allow you to define multiple pre-filtered views of the same data source. This is useful when entities exist in different states and you need a way to toggle between them.
Data views are defined via the Collections settings.
AddDataView()
MethodCreates a data view with the specified name and a where clause filter expression. The expression must return a boolean
value.
AddDataView(string name, Lambda whereClauseExpression) : CollectionConfigBuilder<TEntityType>
collectionConfig.AddDataView("Active", p => p.IsActive);
AddDataView()
Method with GroupCreates a data view within a specified group, using a where clause filter expression. The expression must return a boolean
value.
AddDataView(string group, string name, Lambda whereClauseExpression) : CollectionConfigBuilder<TEntityType>
collectionConfig.AddDataView("Status", "Active", p => p.IsActive);
AddAllDataView
MethodEnables the All
option for data views in the collection. The method can take an empty string, which will display the CMS localized All
value, plain text, or a localized string.
collectionConfig.AddAllDataView(string? label)
Learn how to configure filtering in Umbraco UI Builder.
In addition to Searching, you may need to create specific views of a collection's data. Umbraco UI Builder provides multiple filtering mechanisms to help with this.
Choose a filtering method from the list below to find out more.
Configuring folders to organise trees in Umbraco UI Builder.
Folders help organize trees in Umbraco UI Builder, allowing you to structure content with nested folders and collections. A folder can exist within a tree or as a sub-folder within another folder. Folders can contain either sub-folders or .
To define a folder, use one of the AddFolder
methods on a or parent Folder
config builder instance.
AddFolder()
MethodAdds a folder to the current tree with the specified name and a default folder icon.
AddFolder()
Method with Custom IconAdds a folder to the current tree with a specified name and icon.
When creating a new folder, an alias is automatically generated. However, if you need a specific alias, you can use the SetAlias
method to override it.
SetAlias()
MethodSets a custom alias for a folder.
SetIconColor()
MethodSets the folder icon color to the given color. The available colors are: black
, green
, yellow
, orange
, blue
, or red
.
AddFolder()
Method for Sub-FoldersAdds a sub-folder inside the current folder with a specified name and a default folder icon.
AddFolder()
Method for Sub-Folders with Custom IconAdds a sub folder to the current folder with a specified name and custom icon.
AddCollection<>()
MethodAdds a collection to the current folder with the given names, descriptions, and default icons. The ID property must be defined. For more details, see the article.
AddCollection<>()
Method with Custom IconsAdds a collection to the current folder with the given names, description and icons. The ID property must be defined. For more details, see the article.
Follow the steps to install Umbraco UI Builder into your Umbraco CMS website.
In this article, you will learn how to install Umbraco UI Builder into your Umbraco CMS implementation.
Run the following command in your web project:
For a class library without UI elements, install:
To install via Visual Studio, follow these steps:
Open Visual Studio and load your project.
Go to Tools -> NuGet Package Manager -> Manage NuGet Packages for Solution...
Select the Browse tab and search for Umbraco.UIBuilder.
Select a version from the Version drop-down based on the Umbraco CMS version you are using.
Click Install.
[Optional] Search for and install Umbraco.UIBuilder.Startup if installing without UI elements.
Ensure that the package reference is added to the .csproj file once the installation is complete:
For details on how to install a license, see the article.
Using Umbraco entities as reference with an UI Builder collection
Umbraco stores identifiers in UDI format for most Umbraco object types.
You can read more about them in the section of the documentation.
If you want to reference an Umbraco object in your model and retrieve its Integer
or Guid
value, you must convert the UDI
value.
Use one of UI Builder's converters - EntityIdentifierToIntTypeConverter
or EntityIdentifierToGuidTypeConverter
. Add it as a [TypeConverterAttribute]
to your model's foreign key property.
An entity that references an Umbraco object would look like this:
You can also create a custom type converter. UI Builder will handle data persistence automatically.
Learn how to choose and configure the appropriate area for connecting Umbraco UI builder for Umbraco.
Umbraco UI Builder can be integrated into different areas of the Umbraco Backoffice. Before you start managing content, it is essential to decide which area best suits the presentation of your data. Each area offers unique features for displaying and interacting with content.
Once you have identified the most appropriate area, you can proceed with configuring it to suit your needs.
: The Sections area allows you to organize your content in a structured layout, enabling users to navigate different parts of the backoffice.
: The Dashboards area is ideal for creating custom views that provide quick access to key information and statistics.
: Context Apps provide contextual tools and information based on the specific content a user is working with.
Selecting the correct area is essential to ensure your UI is both functional and user-friendly. Consider the nature of your content and the tasks users need to perform when deciding which area to use.
Learn how to configure actions in Umbraco UI Builder.
Actions allow you to perform custom tasks on collections and their entities from different areas in the UI. For Example: menu actions, bulk actions, or individual table row actions.
To get started with actions, check out the basics:
Configuring child collection groups in Umbraco UI Builder.
This page is a work in progress and may undergo further revisions, updates, or amendments. The information contained herein is subject to change without notice.
A child collection group is a container for other child collections. Its purpose is mainly to provide a logical grouping of multiple child collections to help with organization and an improved user experience.
You can define a child collection group by calling one of the AddChildCollectionGroup
methods on a given collection config builder instance.
AddChildCollectionGroup()
MethodAdds a child collection group to the current collection with the specified name and default icon.
AddChildCollectionGroup()
Method with Custom IconAdds a child collection group to the current collection with the specified name and custom icon.
Get started with Umbraco UI Builder by understanding its system requirements, versioning, and installation prerequisites.
In this article, you will find the requirements to get started with Umbraco UI Builder. Umbraco UI Builder allows you to create and manage custom UI elements for your Umbraco backoffice.
Umbraco 15+ website configured and ready to install Umbraco UI Builder.
To use Umbraco UI Builder, your setup must meet these minimum requirements:
Umbraco CMS version 15+
SQL Server Database (SQLite is acceptable for testing but not recommended for live deployments)
Umbraco UI Builder is an add-on product for Umbraco CMS, and follows the .
Key User Interface Concepts used by Umbraco UI Builder.
Before diving into Umbraco UI Builder, it’s important to understand some of the fundamental concepts of the Umbraco UI. This knowledge will help you navigate and leverage the UI Builder more effectively, as it uses the same UI components to construct interfaces.
A section in Umbraco is a distinct area within the backoffice where related content and functionality are grouped. For example, the Content section is where content management happens, while the Media section handles media files.
The tree represents the hierarchical structure of items within a section. It organizes content, settings, and data, for quick navigation and locating items. For example, the content tree shows the pages of a website in a nested format.
Each section in the Umbraco backoffice typically starts with a dashboard. This is an introductory screen for the section. It often includes useful links or shortcuts, providing an overview or quick access to the most commonly used features.
The collection displays a list of items in a tree or grid view. It provides an overview of content or data in a table format, with sortable columns and the option to filter or search through the items. This view is used when you need to work with multiple items at once.
The editor is where the main content editing occurs. It is structured using tabs, fieldsets, and fields. Tabs organize different sections of content, and fieldsets group related fields together. Each field represents a specific piece of data, such as a text box or an image upload.
Workspace Views are additional functionality that can be added to an editor. They provide extra features based on the content of the item being edited. For instance, a media Workspace View might allow you to resize or crop an image directly from the editor.
Tabs are used to organize content within the editor, allowing users to switch between different sections of a content item. For example, one tab might contain the general settings, while another contains media or advanced options.
A menu item represents an action within the context of a tree node or a list item. It is a clickable item that triggers specific tasks, such as deleting or editing an item.
Bulk actions allow you to perform an operation on multiple items in the list view at once. For example, you might use a bulk action to delete multiple content items or update their status in a single step.
Configure and use the Entity Picker property editor in Umbraco UI Builder to select entities from a collection.
The Entity Picker property editor allows selecting one or more entities from an Umbraco UI Builder collection.
To configure an entity picker, follow these steps:
Go to the Settings section in the Umbraco backoffice.
Create a New Data Type.
Select UI Builder Entity Picker from the Property Editor field.
Enter a Name for the picker and click Save.
Select the Section the collection is located in.
Select the Collection to pick the entities from.
[Optional] Select a list view Data View, if configured.
Enter a Minimum number of items and Maximum number of items that can be selected.
Click Save.
After defining the entity picker Data Type, add it to the desired Document Type.
The entity picker functions similarly to the content picker.
To pick an entity, follow these steps:
Go to the Document Type where the entity picker Data Type is added.
Click Add to open the picker dialog, displaying a paginated list of entities.
[Optional] If searchable fields are configured, use the search input field to filter results.
Click on the entity names.
Click Submit. The picker displays a summary of selected entities, which can be reordered by dragging them.
Click Save or Save and publish to save the changes.
The entity picker property editor includes a built-in . Retrieving the property value from Umbraco returns the selected entities, converting them to the relevant type.
Learn how to configure filterable properties in Umbraco UI Builder.
Umbraco UI Builder dynamically constructs a filter dialog by choosing appropriate editor views based on basic property configurations. Properties of numeric or date types become range pickers, enums become select/checkbox lists, and other properties are text input filters.
Defining filterable properties is controlled via the settings.
AddFilterableProperty()
MethodAdds a given property to the filterable properties collection.
SetLabel()
MethodSets the label for the filterable property.
SetDescription()
MethodSets a description for the filterable property.
SetOptions()
MethodDefines basic options for a filterable property.
AddOption()
MethodDefines options with custom comparison clauses for a filterable property.
For filterable properties with options, you can configure whether the options should allow multiple or single selections.
SetMode()
MethodConfigures the mode of a filterable property (multiple or single choice).
[TableName(TableName)]
[PrimaryKey("Id")]
public class MemberReview
{
public const string TableName = "MemberReview";
[PrimaryKeyColumn]
public int Id { get; set; }
public string Title { get; set; }
public string Content { get; set; }
[TypeConverter(typeof(EntityIdentifierToIntTypeConverter))]
public int MemberId { get; set; }
}
AddFolder(string name, Lambda folderConfig = null) : FolderConfigBuilder
treeConfig.AddFolder("Settings", folderConfig => {
...
});
AddFolder(string name, string icon, Lambda folderConfig = null) : FolderConfigBuilder
treeConfig.AddFolder("Settings", "icon-settings", folderConfig => {
...
});
SetAlias(string alias) : FolderConfigBuilder
folderConfig.SetAlias("settings");
SetIconColor(string color) : FolderConfigBuilder
folderConfig.SetIconColor("blue");
AddFolder (string name, Lambda folderConfig = null) : FolderConfigBuilder
folderConfig.AddFolder("Categories", subFolderConfig => {
...
});
AddFolder (string name, string icon, Lambda folderConfig = null) : FolderConfigBuilder
folderConfig.AddFolder("Categories", "icon-tags", subFolderConfig => {
...
});
AddCollection<TEntityType>(
Lambda idFieldExpression,
string nameSingular,
string namePlural,
string description,
Lambda collectionConfig = null
) : CollectionConfigBuilder<TEntityType>
folderConfig.AddCollection<Person>(
p => p.Id,
"Person",
"People",
"A collection of people",
collectionConfig => {
...
}
);
AddCollection<TEntityType>(
Lambda idFieldExpression,
string nameSingular,
string namePlural,
string description,
string iconSingular,
string iconPlural,
Lambda collectionConfig = null
) : CollectionConfigBuilder<TEntityType>
folderConfig.AddCollection<Person>(
p => p.Id,
"Person",
"People",
"A collection of people",
"icon-umb-users",
"icon-umb-users",
collectionConfig => {
...
}
);
dotnet add package Umbraco.UIBuilder
dotnet add package Umbraco.UIBuilder.Startup
<ItemGroup>
<PackageReference Include="Umbraco.UIBuilder" Version="15.0.2" />
</ItemGroup>
AddChildCollectionGroup(string name, Lambda childCollectionGroupConfig = null) : ChildCollectionGroupConfigBuilder
collectionConfig.AddChildCollectionGroup("Family", childCollectionGroupConfig => {
...
});
AddChildCollectionGroup(string name, string icon, Lambda childCollectionGroupConfig = null) : ChildCollectionGroupConfigBuilder
collectionConfig.AddChildCollectionGroup("Family", "icon-users", childCollectionGroupConfig => {
...
});
// Example
foreach(var p in Model.People){
...
}
AddFilterableProperty(Lambda filterablePropertyExpression, Lambda filterConfig = null) : CollectionConfigBuilder<TEntityType>
collectionConfig.AddFilterableProperty(p => p.FirstName, filterConfig => filterConfig
// ...
);
SetLabel(string label) : FilterablePropertyConfigBuilder<TEntityType, TValueType>
filterConfig.SetLabel("First Name");
SetDescription(string description) : FilterablePropertyConfigBuilder<TEntityType, TValueType>
filterConfig.SetDescription("The first name of the person");
SetOptions(IDictionary<TValueType, string> options) : FilterablePropertyConfigBuilder<TEntityType, TValueType>
filterConfig.SetOptions(new Dictionary<string, string> {
{ "Option1", "Option One" },
{ "Option2", "Option Two" }
});
AddOption(object key, string label, Lambda compareExpression) : FilterablePropertyConfigBuilder<TEntityType, TValueType>
filterConfig.AddOption("Option1", "Option One", (val) => val != "Option Two");
SetMode(FilterMode mode) : FilterablePropertyConfigBuilder<TEntityType, TValueType>
filterConfig.SetMode(FilterMode.MultipleChoice);
Learn how to configure data views builders in Umbraco UI Builder.
Data views builders allow you to create a collection’s data views dynamically at runtime. By default, Umbraco UI Builder uses hard-coded data views from the configuration. However, if you need to generate data views dynamically, a data views builder is required.
When resolving a data views builder, Umbraco UI Builder first attempts to retrieve it from the global Dependency Injection (DI) container. This allows injecting required dependencies into the builder. If no type is defined in the DI container, Umbraco UI Builder falls back to manually instantiating a new instance of the value mapper.
To define a data views builder, create a class that inherits from DataViewsBuilder<TEntityType>
and implements the required abstract methods.
// Example
public class PersonDataViewsBuilder : DataViewsBuilder<Person>
{
public override IEnumerable<DataViewSummary> GetDataViews()
{
// Generate and return a list of data views
}
public override Expression<Func<Person, bool>> GetDataViewWhereClause(string dataViewAlias)
{
// Return a where clause expression for the supplied data view alias
}
}
The required methods are:
GetDataViews: Returns the list of data views to choose from.
GetDataViewWhereClause: Returns the boolean where clause expression for the given data views alias.
Setting a data views builder is controlled via the Collections settings.
SetDataViewsBuilder()
MethodSets the collection's data views builder, allowing you to define data views dynamically at runtime.
SetDataViewsBuilder<TDataViewsBuilder>() : CollectionConfigBuilder<TEntityType>
collectionConfig.SetDataViewsBuilder<PersonDataViewsBuilder>();
SetDataViewsBuilder(Type)
MethodSets the collection's data views builder, allowing you to define data views dynamically at runtime.
SetDataViewsBuilder(Type dataViewsBuilderType) : CollectionConfigBuilder<TEntityType>
collectionConfig.SetDataViewsBuilder(typeof(PersonDataViewsBuilder));
SetDataViewsBuilder(DataViewsBuilder<TEntityType>)
MethodSets the collection's data views builder, allowing you to define data views dynamically at runtime.
SetDataViewsBuilder(DataViewsBuilder<TEntityType> dataViewsBuilder) : CollectionConfigBuilder<TEntityType>
collectionConfig.SetDataViewsBuilder(new PersonDataViewsBuilder());
Learn how to configure custom cards in Umbraco UI Builder.
Custom cards enable more complex metric calculations and are defined by a class that implements the Card
base class.
When Umbraco UI Builder resolves a card, it tries to do so from the global DI container. This means you can inject any dependencies required for the card's value calculation. If no type is found in the DI container, Umbraco UI Builder will fall back to manually instantiating a new instance of the value mapper.
To define a custom card, create a class that inherits from the base class Card
and configure it in the constructor as shown below:
// Example
public class AvgPersonAgeCard : Card
{
public override string Alias => "avgPersonAge";
public override string Name => "Average Age";
public override string Icon => "icon-calendar";
public override string Color => "green";
public override string Suffix => "yrs";
public override object GetValue(object parentId = null)
{
// Perform value calculation logic
}
}
Name
The name of the card.
Yes
Alias
A unique alias for the card.
Yes
GetValue(object parentId = null)
A method to retrieve the card's value.
Yes
Icon
An icon displaed in the card.
No
Color
The color of the card.
No
Suffix
The suffix displayed after the card value.
No
AddCard()
MethodAdds a custom card of the specified type to the collection.
AddCard() : CollectionConfigBuilder<TEntityType>
collectionConfig.AddCard<AvgPersonAgeCard>();
AddCard(Type cardType)
MethodAdds a custom card of the specified type to the collection, using the Type
parameter to pass the card type dynamically.
AddCard(Type cardType) : CollectionConfigBuilder<TEntityType>
collectionConfig.AddCard(typeof(AvgPersonAgeCard));
Learn how to configure count cards in Umbraco UI Builder.
Count cards allow you to define cards directly against the Collection configuration, providing a basic where clause to use in a count SQL statement. These work perfectly for basic data visualizations based on counts of entities in a collection.
If you need to do more than a basic count, see the Custom Cards article.
Count cards display basic summaries of key information that may be useful to the editor.
AddCard()
MethodAdds a count card with the specified name and a where clause filter expression. The filter expression must be a boolean
value.
AddCard(string name, Lambda whereClauseExpression, Lambda cardConfig = null) : CardConfigBuilder
collectionConfig.AddCard("Older than 30", p => p.Age > 30, cardConfig => {
...
});
AddCard()
Method with IconAdds a count card with the specified name, an icon, and a where clause filter expression. The filter expression must be a boolean
value.
AddCard(string name, string icon, Lambda whereClauseExpression, Lambda cardConfig = null) : CardConfigBuilder
collectionConfig.AddCard("Older than 30", "icon-umb-users", p => p.Age > 30, cardConfig => {
...
});
SetColor()
MethodSets the color for the count card.
SetColor(string color) : CardConfigBuilder
cardConfig.SetColor("blue");
SetSuffix()
MethodSets a suffix to be displayed alongside the card value.d
SetSuffix(string suffix) : CardConfigBuilder
cardConfig.SetSuffix("years");
SetFormat()
MethodSets a custom format for the card's value.
SetFormat(Lambda formatExpression) : CardConfigBuilder
cardConfig.SetFormat((v) => $"{v}%");
Configuring value mappers in Umbraco UI Builder to modify how data is stored and retrieved.
Value mappers in Umbraco UI Builder act as intermediaries between the editor UI and the database, allowing customization of stored field values. By default, Umbraco UI Builder saves data as it would be stored in Umbraco, but value mappers enable modifications.
When resolving a value mapper, Umbraco UI Builder first checks the global DI container. If no type is defined, it manually instantiates a new instance.
To define a mapper, create a class that inherits from the base class ValueMapper
and implements the EditorToModel
and ModelToEditor
methods.
public class MyValueMapper : ValueMapper
{
public override object EditorToModel(object input)
{
// Tweak the input and return mapped object
...
}
public override object ModelToEditor(object input)
{
// Tweak the input and return mapped object
...
}
}
Value mappers are defined as part of a collection editor field configuration.
SetValueMapper()
MethodSet the value mapper for the current field.
SetValueMapper<TMapperType>() : EditorFieldConfigBuilder<TEntityType, TValueType>
fieldConfig.SetValueMapper<MyValueMapper>();
SetValueMapper(Type mapperType)
MethodSet the value mapper for the current field using a type reference.
SetValueMapper(Type mapperType) : EditorFieldConfigBuilder<TEntityType, TValueType>
fieldConfig.SetValueMapper(typeof(MyValueMapper));
SetValueMapper(Mapper mapper)
MethodSet the value mapper for the current field using an instance.
SetValueMapper(Mapper mapper) : EditorFieldConfigBuilder<TEntityType, TValueType>
fieldConfig.SetValueMapper(new MyValueMapper());
Configuring one-to-many relationships in Umbraco UI Builder.
This page is a work in progress and may undergo further revisions, updates, or amendments. The information contained herein is subject to change without notice.
In one-to-many relationships, a parent entity is associated with multiple entities from another collection. In Umbraco UI Builder, retrieving child collections from such relationships is supported through child repositories. This enables you to access related data effectively, helping to maintain a well-organized backoffice UI.
For a one-to-many relationship, you typically have two models: one for the parent entity and one for the child entity.
[TableName("Students")]
[PrimaryKey("Id")]
public class Student
{
[PrimaryKeyColumn]
public int Id { get; set; }
public string FirstName { get; set; }
public string LastName { get; set; }
public string Email { get; set; }
}
In the above example, the Student
model represents the parent entity. A student can have multiple associated StudentProjects
.
[TableName("StudentProjects")]
[PrimaryKey("Id")]
public class StudentProject
{
[PrimaryKeyColumn]
public int Id { get; set; }
public string Name { get; set; }
public int StudentId { get; set; }
}
The StudentProjects
model represents the child entity. The StudentId
is a foreign key that links each StudentProject
to the Student
entity, establishing the one-to-many relationship.
To retrieve data from child collections, you can use the IRepositoryFactory
to create child repository instances. These repositories provide methods to fetch child entities associated with a given parent entity.
public class StudentProjectController : Controller
{
private readonly IRepositoryFactory _repositoryFactory;
public StudentProjectController(IRepositoryFactory repositoryFactory)
{
_repositoryFactory = repositoryFactory;
}
public IActionResult Index(int projectId)
{
var childRepository = _repositoryFactory.GetChildRepository<int, StudentProject, int>(projectId);
var list = childRepository.GetAll();
var count = childRepository.GetCount();
var listPaged = childRepository.GetPaged();
return View(list);
}
}
In this example:
The StudentProjectController
is using the IRepositoryFactory
to create a child repository for StudentProject
.
The GetAll()
method retrieves all child entities related to the given parent.
The GetCount()
method returns the total number of child entities associated with the parent.
The GetPaged()
method allows for pagination of child entities, making it easier to manage large sets of data.
This structure allows efficient retrieval and management of child entities, providing a well-organized way to interact with related data in Umbraco's backoffice.
Get an overview of the things changed and fixed in each version of Umbraco UI Builder.
This section summarizes the changes and fixes introduced in each version of Umbraco UI Builder. Each release includes a link to the UI Builder issue tracker, where you can find a list of resolved issues. Individual issues are also linked for more details.
If there are any breaking changes or other issues to be aware of when upgrading they are also noted here.
Below are the release notes for Umbraco UI Builder, detailing all changes in this version.
Upgraded to run on Umbraco version 16.
You can find the release notes for Konstrukt in the Change log file on GitHub.
Configuring the list view of a collection in Umbraco UI Builder.
A list view displays a collection entity in a list format and includes features like pagination, custom data views, searching, and bulk actions.
The list view configuration is a sub-configuration of a Collection
config builder instance and can be accessed via the ListView
method.
ListView()
MethodAccesses the list view configuration for the specified collection.
ListView(Lambda listViewConfig = null) : ListViewConfigBuilder<TEntityType>
collectionConfig.ListView(listViewConfig => {
...
});
AddField()
MethodAdds a specified property to the list view.
AddField(Lambda propertyExpression, Lambda fieldConfig = null) : ListViewFieldConfigBuilder<TEntityType, TValueType>
listViewConfig.AddField(p => p.FirstName, fieldConfig => {
...
});
SetHeading()
MethodSets the heading for a field in the list view.
SetHeading(string heading) : ListViewFieldConfigBuilder<TEntityType, TValueType>
fieldConfig.SetHeading("First Name");
SetFormat()
MethodSets the format expression to the field in the list view.
SetFormat(Lambda formatExpression) : ListViewFieldConfigBuilder<TEntityType, TValueType>
fieldConfig.SetFormat((v, p) => $"{v} years old");
You can customize the field's markup with field views, allowing richer visualizations of the content. For more details, see the Field Views article.
SetView()
MethodSets the view component for the list view field.
SetView(string viewComponentName) : ListViewFieldConfigBuilder<TEntityType, TValueType>
fieldConfig.SetView("ImageFieldView");
SetView<TView>()
MethodSets the view component for the list view field.
SetView<TView>() : ListViewFieldConfigBuilder<TEntityType, TValueType>
fieldConfig.SetView<ImageFieldView>();
SetVisibility()
MethodControls the runtime visibility of a field in the list view.
SetVisibility(Predicate<ListViewFieldVisibilityContext> visibilityExpression) : ListViewFieldConfigBuilder<TEntityType, TValueType>
fieldConfig.SetVisibility(ctx => ctx.UserGroups.Any(x => x.Alias == "editor"));
SetPageSize
MethodSets the number of items per page for the list view.
SetPageSize(int pageSize) : ListViewConfigBuilder<TEntityType>
listViewConfig.SetPageSize(20);
Configure searchable properties in Umbraco UI Builder.
Searchable properties allow you to define any String
based properties in a model. It can be searched via Umbraco UI Builder's list view and entity picker search controls.
Both direct String
properties and String
properties within nested objects can be made searchable, provided the parent object is not null
.
AddSearchableProperty()
MethodUse AddSearchableProperty
to specify which properties should be included in search functionality.
AddSearchableProperty(Lambda searchablePropertyExpression) : CollectionConfigBuilder<TEntityType>
collectionConfig.AddSearchableProperty(p => p.FirstName);
collectionConfig.AddSearchableProperty(p => p.Address.Street);
The search behavior differs based on the version:
Up to version 15.0.1: Search uses the StartsWith
method, meaning results include entries that begin with the search term.
Version 15.0.1 and later: Search can be configured to use Contains
, allowing results that include the search term anywhere within the property value.
collectionConfig.AddSearchableProperty(p => p.FirstName); // will search for keywords that start with.
collectionConfig.AddSearchableProperty(p => p.FirstName, SearchExpressionPattern.Contains); // will search for keywords that are contained.
Configuring Dashboards in Umbraco UI Builder.
Dashboards in Umbraco UI Builder provide an intuitive way to present important information and tools at the root of a section within the Umbraco backoffice. They serve as a starting point for users, offering quick access to relevant data, insights, or actions. Dashboards can be customized, reordered, and configured to display for specific user groups, making them a flexible tool for enhancing the backoffice experience. When multiple dashboards are available in a section, they appear in a tabbed layout for easy navigation.
You can define a dashboard by calling one of the AddDashboard
methods on a or a instance.
AddDashboard()
MethodAdds a dashboard with the specified name.
AddDashboardBefore()
MethodAdds a dashboard with the specified name before the dashboard with the given alias.
AddDashboardAfter()
MethodAdds a dashboard with the specified name after the dashboard with the given alias.
SetAlias()
MethodSets the alias of the dashboard. By default, an alias is automatically generated based on the supplied name. If a specific alias is required, the SetAlias
method can be used to override the default.
Dashboard visibility can be controlled using ShowForUserGroup
and HideForUserGroup
, which specify which user groups can see the dashboard. These settings can be applied multiple times for different user roles.
By default, dashboards are pre-filtered to display only in their defined section. This filtering is combined with the SetVisibility
method to control when a dashboard appears.
SetVisibility()
MethodDefines visibility rules for the dashboard.
A dashboard can display only one collection. To display multiple collections, multiple dashboards must be configured.
SetCollection<>()
MethodAssigns a collection to the dashboard with the specified names, descriptions, and default icons. The ID property must be defined. For more details, see the article.
SetCollection<>()
Method with Custom IconsAssigns a collection to the dashboard with the specified names, descriptions, and custom icons. The ID property must be defined. For more details, see the article.
Learn about licensing, including coverage, installation, and validation options.
Umbraco UI Builder is a commercial product. You can use Umbraco UI Builder locally without a license. When running Umbraco UI Builder on a public domain the usage is limited to a single editable collection. To remove these restrictions, a valid license is required.
Licenses are sold per backoffice domain and applies to all subdomains. If you have alternative staging/QA environment domains, additional domains can be added to the license on request.
A license for mysite.com
and requested dev domains (devdomain.com
and devdomain2.com
) will cover:
localhost
*.local
*.mysite.com
www.mysite.com
devdomain.com
www.devdomain.com
devdomain2.com
www.devdomain2.com
There are a few differences as to what the licenses cover:
A single license covers the installation of Umbraco UI Builder in one production backoffice domain, as well as in any requested development domains.
The production domain includes all subdomains (e.g. *.mysite.com
).
The development domains work with or without the www
subdomain.
The license allows for an unlimited number of editable collections.
The license also includes localhost
and *.local
as a valid domain.
You can look at the pricing, features, and purchase a license on the page. On this page, you can fill out the form with your project details and requirements.
A member of the Sales team will manage this process. In the process, you will need to provide all domains you wish to have covered by the license such as primary and staging/QA domains. You should then receive a license code to be installed in your solution.
If you require to add additional domains to the license, . They will manage your request and take care of the process.
Once you have received your license code it needs to be installed on your site.
Open the root directory of your project files.
Locate and open the appSettings.json
file.
Add your Umbraco UI builder license key under Umbraco:Licenses:Products:Umbraco.UIBuilder
:
To verify that your license is successfully installed:
Log into Umbraco Backoffice.
Navigate to the Settings > License dashboard.
Verify the license status displayed on the dashboard.
Some Umbraco installations will have a highly locked down production environment, with firewall rules that prevent outgoing HTTP requests. This will interfere with the normal process of license validation.
On start-up, and periodically whilst Umbraco is running, the license component used by Umbraco UIBuilder will make an HTTP POST request to https://license-validation.umbraco.com/api/ValidateLicense
.
If it's possible to do so, the firewall rules should be adjusted to allow this request.
If such a change is not feasible, there is another approach you can use.
You will need to have a server, or serverless function, that is running and can make a request to the online license validation service. That needs to run on a daily schedule, making a request and relaying it onto the restricted Umbraco environment.
To set this up, firstly ensure you have a reference to Umbraco.Licenses
version 13.1 or higher. If the version of UIBuilder you are using depends on an earlier version, you can add a direct package reference for Umbraco.Licenses
.
Then configure a random string as an authorization key in configuration. This is used as protection to ensure only valid requests are handled. You can also disable the normal regular license checks - as there is no point in these running if they will be blocked:
Your Internet enabled server should make a request of the following form to the online license validation service:
The response should be relayed exactly via an HTTP request to your restricted Umbraco environment:
A header with a key of X-AUTH-KEY
and value of the authorization key you have configured should be provided.
This will trigger the same processes that occur when the normal scheduled validation completes ensuring your product is considered licensed.
Configure repositories in Umbraco UI Builder.
Repositories in Umbraco UI Builder manage entity data storage. By default, collections use a built-in NPoco repository. To use a different storage strategy, define a custom repository implementation.
Create a class that inherits from Repository<TEntity, TId>
and implements all abstract methods.
SetRepositoryType()
MethodAssign a custom repository type to a collection.
SetRepositoryType(Type repositoryType)
MethodSets the repository type dynamically to the given type for the current collection.
To help with accessing a repository (default or custom) Umbraco UI Builder has an IRepositoryFactory
you can inject into your code base. This includes a couple of factory methods to create the repository instances for you.
Repositories should only be created via the repository factory as there are some injected dependencies that can only be resolved by Umbraco UI Builder.
GetRepository<TEntity, TId>()
MethodCreates a repository for the given entity type. Umbraco UI Builder will search the configuration for the first section/collection with a configuration for the given entity type. Then it will use that as a repository configuration.
GetRepository<TEntity, TId>(string collectionAlias)
MethodCreates a repository for the given entity type from the collection with the given alias.
Step-by-step guide to migrating a Konstrukt solution to Umbraco UI Builder.
This guide walks you through migrating a default Konstrukt solution to Umbraco UI Builder.
Before starting, review these key changes that impact the migration process.
Replace all existing Konstrukt dependencies with Umbraco UI Builder dependencies.
Remove existing Konstrukt packages:
Delete the Konstrukt App_Plugins
folder:
Install Umbraco.UIBuilder
:
Compile your project against .NET 7.0.
Update all Konstrukt references to their Umbraco UI Builder alternatives. Ensure you update any Views/Partials that also reference these. See the section for reference.
If your configuration is in a single statement, replace AddKonstrukt
with AddUIBuilder
.
For multi-step configurations using Action
or Card
classes, update the config builders and base classes to their UI Builder alternatives as described in .
Delete obj/bin
folders for a clean build.
Recompile all projects and ensure all dependencies are restored correctly.
Remove existing Konstrukt license files from umbraco\Licenses
folder.
Add your Umbraco.UIBuilder license key to the appSettings.json
file:
Run the project.
Configuring event handlers in Umbraco UI Builder.
Umbraco UI Builder triggers different notification events during operation, allowing customization of default behavior.
Umbraco UI Builder follows the for event registration.
Define a notification event handler for the target event:
Register the event handler in Program.cs
:
EntitySavingNotification()
Triggers when Save
is called before persisting the entity. The notification contains an Entity
property with Before
and After
values, providing access to the previous and updated entities. Modify the After
entity to persist changes. If the Cancel
property of the notification is set to true
then the save operation will be canceled and no changes will be saved.
EntitySavedNotification()
Triggers when the repository Save
method is called and after the entity has been persisted. The notification contains an Entity
property with Before
and After
inner properties. These properties provide access to a copy of the previously persisted entity (or null if a new entity) and the updated entity that´s saved.
EntityDeletingNotification()
Triggers when the repository Delete
method is called and before the entity is deleted. The notification contains an Entity
property providing access to a copy of the entity about to be deleted. If the Cancel
property of notification is set to true
then the delete operation will be cancelled and entity won't be deleted.
EntityDeletedNotification()
Triggers when the repository Delete
method is called and after the entity has been deleted. The notification contains an Entity
property providing access to a copy of the entity that´s deleted.
SqlQueryBuildingNotification()
Triggers when the repository is preparing a SQL query. The notification contains the collection alias + type, the NPoco Sql<ISqlContext>
object, and the where clause/order by clauses. These will be used to generate the SQL query.
SqlQueryBuiltNotification()
Triggers when the repository has repaired a SQL query. The notification contains the collection alias + type, the NPoco Sql<ISqlContext>
object and the where clause/order by clauses that was used to generate the SQL query.
From version 15.1.0
, complex server-side validation can be added to a collection using the CancelOperation
method of the notification.
// Example
public class PersonRepository : Repository<Person, int> {
public PersonRepository(RepositoryContext context)
: base(context)
{ }
protected override int GetIdImpl(Person entity) {
return entity.Id;
}
protected override Person GetImpl(int id) {
...
}
protected override Person SaveImpl(Person entity) {
...
}
protected override void DeleteImpl(int id) {
...
}
protected override IEnumerable<Person> GetAllImpl(Expression<Func<Person, bool>> whereClause, Expression<Func<Person, object>> orderBy, SortDirection orderByDirection) {
...
}
protected override PagedResult<Person> GetPagedImpl(int pageNumber, int pageSize, Expression<Func<Person, bool>> whereClause, Expression<Func<Person, object>> orderBy, SortDirection orderByDirection) {
...
}
protected override long GetCountImpl(Expression<Func<Person, bool>> whereClause) {
...
}
protected override IEnumerable<TJunctionEntity> GetRelationsByParentIdImpl<TJunctionEntity>(int parentId, string relationAlias)
{
...
}
protected override TJunctionEntity SaveRelationImpl<TJunctionEntity>(TJunctionEntity entity)
{
...
}
}
SetRepositoryType<TRepositoryType>() : CollectionConfigBuilder<TEntityType>
collectionConfig.SetRepositoryType<PersonRepositoryType>();
SetRepositoryType(Type repositoryType) : CollectionConfigBuilder<TEntityType>
collectionConfig.SetRepositoryType(typeof(PersonRepositoryType));
IRepositoryFactory.GetRepository<TEntity, TId>() : Repository<TEntity, TId>
public class MyController : Controller
{
private readonly Repository<Person, int> _repo;
public MyController(IRepositoryFactory repoFactory)
{
_repo = repoFactory.GetRepository<Person, int>();
}
}
IRepositoryFactory.GetRepository<TEntity, TId>(string collectionAlias) : Repository<TEntity, TId>
public class MyController : Controller
{
private readonly Repository<Person, int> _repo;
public MyController(IRepositoryFactory repoFactory)
{
_repo = repoFactory.GetRepository<Person, int>("person");
}
}
"Umbraco": {
"Licenses": {
"Products": {
"Umbraco.UIBuilder": "YOUR_LICENSE_KEY"
}
}
}
"Umbraco_UIBuilder": "YOUR_LICENSE_KEY"
"Umbraco": {
"Licenses": {
"Umbraco.UIBuilder": "<your license key>"
},
"LicensesOptions": {
"EnableScheduledValidation": false,
"ValidatedLicenseRelayAuthKey": "<your authorization key>"
}
POST https://license-validation.umbraco.com/api/ValidateLicense
{
"ProductId": "Umbraco.UIBuilder",
"LicenseKey": "<your license key>",
"Domain": "<your licensed domain>"
}
POST http://<your umbraco environment>/umbraco/licenses/validatedLicense/relay?productId=<product id>&licenseKey=<license key>
Konstrukt.Core
Umbraco.UIBuilder.Core
Konstrukt.Infrastructure
Umbraco.UIBuilder.Infrastructure
Konstrukt.Web
Umbraco.UIBuilder.Web
Konstrukt.Web.UI
Umbraco.UIBuilder.Web.StaticAssets
Konstrukt.Startup
Umbraco.UIBuilder.Startup
Konstrukt
Umbraco.UIBuilder
dotnet remove package Konstrukt
rmdir App_Plugins\Konstrukt
dotnet add package Umbraco.UIBuilder
builder.CreateUmbracoBuilder()
.AddBackOffice()
.AddWebsite()
.AddDeliveryApi()
.AddComposers()
.AddUIBuilder(cfg => {
// The rest of your configuration
})
.Build();
"Umbraco": {
"Licenses": {
"Umbraco.UIBuilder": "YOUR_LICENSE_KEY"
}
}
public class MyEntitySavingEventHandler : INotificationHandler<EntitySavingNotification> {
public void Handle(EntitySavingNotification notification)
{
// Handle the event here
}
}
builder.CreateUmbracoBuilder()
.AddBackOffice()
.AddWebsite()
.AddDeliveryApi()
.AddComposers()
.AddNotificationHandler<EntitySavingNotification, MyEntitySavingEventHandler>()
.Build();
public class MyEntitySavingEventHandler : INotificationHandler<EntitySavingNotification> {
public void Handle(EntitySavingNotification notification)
{
var person = notification.Entity.After as Person;
if (person != null){
...
}
}
}
public class MyEntitySavedEventHandler : INotificationHandler<EntitySavedNotification> {
public void Handle(EntitySavedNotification notification)
{
var person = notification.Entity.After as Person;
if (person != null){
...
}
}
}
public class MyEntityDeletingEventHandler : INotificationHandler<EntityDeletingNotification> {
public void Handle(EntityDeletingNotification notification)
{
var person = notification.Entity.After as Person;
if (person != null){
...
}
}
}
public class MyEntityDeletedEventHandler : INotificationHandler<EntityDeletedNotification> {
public void Handle(EntityDeletedNotification notification)
{
var person = notification.Entity.After as Person;
if (person != null){
...
}
}
}
public class MySqlQueryBuildingEventHandler : INotificationHandler<SqlQueryBuildingNotification> {
public void Handle(SqlQueryBuildingNotification notification)
{
notification.Sql = notification.Sql.Append("WHERE MyId = @0", 1);
}
}
public class MySqlQueryBuiltEventHandler : INotificationHandler<SqlQueryBuiltNotification> {
public void Handle(SqlQueryBuiltNotification notification)
{
notification.Sql = notification.Sql.Append("WHERE MyId = @0", 1);
}
}
public class MyEntitySavingEventHandler : INotificationHandler<EntitySavingNotification> {
public void Handle(EntitySavingNotification notification)
{
var person = notification.Entity.After as Person;
if (person != null && person.Age < 18) {
notification.CancelOperation(new EventMessage("ValidationError", "Custom validation error message raised from the notification handler"));
}
}
}
AddDashboard(string name, Lambda dashboardConfig = null) : DashboardConfigBuilder
sectionConfig.AddDashboard("Team", dashboardConfig => {
...
});
AddDashboardBefore(string beforeAlias, string name, Lambda dashboardConfig = null) : DashboardConfigBuilder
sectionConfig.AddDashboardBefore("contentIntro", "Team", dashboardConfig => {
...
});
AddDashboardAfter(string afterAlias, string name, Lambda dashboardConfig = null) : DashboardConfigBuilder
sectionConfig.AddDashboardAfter("contentIntro", "Team", dashboardConfig => {
...
});
SetAlias(string alias) : DashboardConfigBuilder
dashboardConfig.SetAlias("team");
SetVisibility(Lambda visibilityConfig) : DashboardConfigBuilder
dashboardConfig.SetVisibility(visibilityConfig => visibilityConfig
.ShowForUserGroup("admin")
.HideForUserGroup("translator")
);
SetCollection<TEntityType>(
Lambda idFieldExpression,
string nameSingular,
string namePlural,
string description,
Lambda collectionConfig = null
) : ContextAppConfigBuilder
dashboardConfig.SetCollection<Comment>(
p => p.Id,
"Team Member",
"Team Members",
"A collection of team members",
collectionConfig => {
...
}
);
SetCollection<TEntityType>(
Lambda idFieldExpression,
Lambda fkFieldExpression,
string nameSingular,
string namePlural,
string description,
string iconSingular,
string iconPlural,
Lambda collectionConfig = null
) : ContextAppConfigBuilder
dashboardConfig.SetCollection<Comment>(
p => p.Id,
p => p.ForeignKey,
"Team Member",
"Team Members",
"A collection of team members",
"icon-umm-user",
"icon-umb-user",
collectionConfig => {
...
}
);
Common Umbraco aliases used in Umbraco UI Builder for Sections, Dashboards, Workspace Views, and Trees.
Umbraco UI Builder requires aliases for different elements, such as sections, context apps, and dashboards. While aliases for elements defined in the UI Builder config are straightforward, finding aliases for existing Umbraco instances can be challenging. Below is a list of known aliases for reference.
Getting Started
contentIntro
Redirect URL Management
contentRedirectManager
Content
mediaFolderBrowser
Welcome
settingsWelcome
Examine Management
settingsExamine
Published Status
settingsPublishedStatus
Models Builder
settingsModelsBuilder
Health Check
settingsHealthCheck
Getting Started
memberIntro
Content
umbContent
Info
umbInfo
Content
umbContent
Info
umbInfo
Content
umbContent
Info
umbInfo
Design
design
List View
listView
Permissions
permissions
Templates
templates
Content
content
Media
media
Settings
settings
Packages
packages
Users
users
Members
member
Forms
forms
Translation
translation
Content
content
Media
media
Members
member
Member Groups
memberGroups
Configuring actions in Umbraco UI Builder.
Actions allow you to add custom functionality to Umbraco UI Builder without creating custom UI elements. By providing an action to run, Umbraco UI Builder can trigger actions from different UI locations.
To define an action, create a class that inherits from the base class Action<>
and configure it as shown below:
// Example
public class MyAction : Action<ActionResult>
{
public override string Icon => "icon-settings";
public override string Alias => "myaction";
public override string Name => "My Action";
public override bool ConfirmAction => true;
public override ActionResult Execute(string collectionAlias, object[] entityIds)
{
// Perform operation here...
}
}
Name
The name of the action.
Yes
Alias
A unique alias for the action.
Yes
Icon
An icon to display next to the action’s name.
Yes
Execute
The method that runs for the given list of entities.
Yes
ConfirmAction
Set whether a confirm dialog should display before performing this action.
No
The generic argument specifies the return type for the action. For more details, see the Controlling the Action Result section below.
By default, actions return an ActionResult
, but you can return other types by changing the Action<>
generic argument.
ActionResult
- Standard result with a boolean Success
value.
FileActionResult
- Returns a file stream or bytes and triggers a download dialog.
Sometimes, you need to collect user input before performing an action. You can achieve this by using the Action<>
base class with an additional TSetting
generic argument.
// Example
public class MyAction : Action<MyActionSettings, ActionResult>
{
public override string Icon => "icon-settings";
public override string Alias => "myaction";
public override string Name => "My Action";
public override bool ConfirmAction => true;
public override void Configure(SettingsConfigBuilder<MyActionSettings> settingsConfig)
{
settingsConfig.AddFieldset("General", fieldsetConfig => fieldsetConfig
.AddField(s => s.RecipientName).SetLabel("Recipient Name")
.AddField(s => s.RecipientEmail).SetLabel("Recipient Email"));
}
public override ActionResult Execute(string collectionAlias, object[] entityIds, MyActionSettings settings)
{
// Perform operation here...
}
}
public class MyActionSettings
{
public string RecipientName { get; set; }
public string RecipientEmail { get; set; }
}
By implementing this base class, you must also implement the Configure
method which accepts a SettingsConfigBuilder<>
parameter. Use this builder to define the settings dialog UI and how it maps to the settings type. You can create fieldsets and fields with the same fluent API as in the Collection Editors section.
Additionally, the Execute
method now accepts an extra settings
parameter, which Umbraco UI Builder will pre-populate with the user-entered values. You can adjust the action's behavior based on this data.
Actions are added via the Collections settings.
AddAction<TMenuActionType>()
MethodAdds an action of the specified type to the collection.
AddAction<TMenuActionType>() : CollectionConfigBuilder<TEntityType>
collectionConfig.AddAction<ExportMenuAction>();
AddAction(Type actionType)
MethodAdds an action of the specified type to the collection.
AddAction(Type actionType) : CollectionConfigBuilder<TEntityType>
collectionConfig.AddAction(actionType);
AddAction(IAction action)
MethodAdds the given action to the collection.
AddAction(IAction action) : CollectionConfigBuilder<TEntityType>
collectionConfig.AddAction(action);
Controlling the visibility of actions in Umbraco UI Builder.
By default, actions are hidden in the UI. You must define when and where an action should appear. This can be done either at the action definition level or when registering it in the collection config.
To define the default visibility of an action, override the IsVisible
method of the Action<>
base class.
// Example
public class MyAction : Action<ActionResult>
{
...
public override bool IsVisible(ActionVisibilityContext ctx)
{
return ctx.ActionType == ActionType.Bulk
|| ctx.ActionType == ActionType.Row;
}
...
}
The IsVisible
method receives an ActionVisibilityContext
. You can use this context to decide whether the action should be displayed. Return true
to show it, or false
to hide it. For more information, see the Action visibility context section below.
You can override an action's visibility in the Collections settings.
AddAction<TMenuActionType>()
MethodAdds an action of the given type to the collection with the specified visibility.
AddAction<TMenuActionType>(Lambda actionConfig = null) : CollectionConfigBuilder<TEntityType>
collectionConfig.AddAction<ExportMenuAction>(actionConfig => actionConfig
.SetVisibility(x => x.ActionType == ActionType.Bulk
|| x.ActionType == ActionType.Row)
);
AddAction(Type actionType, Lambda actionConfig = null)
MethodAdds an action of the given type to the collection by specifying the action type dynamically using Type
instead of a generic type.
AddAction(Type actionType, Lambda actionConfig = null) : CollectionConfigBuilder<TEntityType>
collectionConfig.AddAction(typeof(ExportMenuAction), actionConfig => actionConfig
.SetVisibility(x => x.ActionType == ActionType.Bulk
|| x.ActionType == ActionType.Row)
);
AddAction(IAction action, Lambda actionConfig = null)
MethodAdds the already defined action instance to the collection with the specified visibility.
AddAction(IAction action, Lambda actionConfig = null) : CollectionConfigBuilder<TEntityType>
collectionConfig.AddAction(action, actionConfig => actionConfig
.SetVisibility(x => x.ActionType == ActionType.Bulk
|| x.ActionType == ActionType.Row)
);
When controlling the visibility of an action, you will receive an ActionVisibilityContext
object. This context allows you to decide whether to show the action. The context contains two key pieces of information for this decision.
The ActionType
property is an enum property that defines which area of the UI wants to access the action. This property helps determine where the action is displayed.
The ContainerMenu
action type displays the action in both the collection tree and its list view actions menu.
The EntityMenu
action type shows the action in the collection editor UI's actions menu.
The Bulk
action type displays the action in the collection list view bulk actions menu.
The Row
action type shows the action in the collection list view action row menu.
The Save
action type displays the action as a sub-button in the entity editor’s save button. All Save
actions trigger a save before executing. Their labels are prefixed with Save & [Action Name]
.
The UserGroups
collection contains a list of IReadOnlyUserGroup
objects for the current logged-in backoffice user. This allows you to control action visibility for members of specific user groups.
Configuring and customizing sections in Umbraco UI Builder to organize and manage the backoffice interface effectively.
A section in Umbraco represents a distinct area within the backoffice, such as content, media, and so on. Sections are accessible via links in the main menu at the top of the Umbraco interface. Using Umbraco UI Builder, multiple sections can be defined to organize the management of models logically.
Sections are defined using the AddSection
method on the root-level UIBuilderConfigBuilder
instance.
AddSection()
MethodThis method adds a new section to the Umbraco menu with the specified name, allowing custom areas for organizing content in the backoffice.
AddSectionBefore()
MethodThis method adds a section before another section with the specified alias, allowing for customized ordering of sections in the backoffice.
AddSectionAfter()
MethodThis method adds a section after another section with the specified alias, allowing for a custom order of sections in the backoffice.
SetAlias()
MethodThis method sets a custom alias for the section.
Optional: By default, an alias is automatically generated from the section's name. To customize the alias, the SetAlias()
method can be used.
Tree()
Method for ConfigurationThis method configures the tree structure for the section, which is used to organize content types. For more information, see the article.
AddDashboard()
MethodThis method adds a dashboard to the section with the specified alias, providing tools and features for content management. For more information, see the article.
AddDashboardBefore()
to Place a DashboardThis method adds a dashboard before another dashboard with the specified alias, allowing custom placement in the section. For more information, see the article.
AddDashboardAfter()
to Place a DashboardThis method adds a dashboard after another dashboard with the specified alias, giving control over dashboard order. For more information, see the article.
You can extend existing sections by adding Umbraco UI Builder trees and dashboards, context apps, and virtual subtrees. This can be done by calling the WithSection
method on the root-level UIBuilderConfigBuilder
instance.
WithSection()
This method extends an existing section with additional configuration, enabling more customization for existing areas.
AddTree()
MethodThis method adds a tree to the section, helping to visualize and organize content types. For more information, see the article.
AddTree()
MethodThis method adds a tree within a specified group, improving content organization by grouping related trees together. For more information, see the article.
AddTreeBefore()
to Position a TreeThis method adds a tree before another tree within the section, allowing you to customize the tree order. For more information, see the article.
AddTreeAfter()
to Position a TreeThis method adds a tree after another tree within the section, enabling specific ordering of trees. For more information, see the article.
AddDashboard()
MethodThis method adds a new dashboard to the section with the specified name. For more information, see the article.
AddDashboardBefore()
MethodThis method adds a dashboard before the dashboard with the specified alias. For more information, see the article.
AddDashboardAfter()
MethodThis method adds a dashboard after the dashboard with the specified alias. For more information, see the article.
Configuring virtual sub trees in Umbraco UI Builder.
This page is a work in progress and may undergo further revisions, updates, or amendments. The information contained herein is subject to change without notice.
Virtual subtrees inject an Umbraco UI Builder tree structure into another Umbraco tree at a specified location, acting as child nodes of the injection point. They extend built-in or third-party package trees with additional features. For example a "loyalty points" program for an e-commerce site can inject related database tables into a Commerce store tree, making management more intuitive.
Use the AddVirtualSubTree
methods of a instance to define a virtual subtree.
AddVirtualSubTree()
MethodAdds a virtual subtree to the current tree with visibility controlled by the specified expression.
AddVirtualSubTreeBefore()
MethodAdds a virtual subtree to the current tree before the tree node matches the match expression, with its visibility controlled by the specified expression.
AddVirtualSubTreeAfter()
MethodAdds a virtual subtree to the current tree after the tree node matches the match expression, with its visibility controlled by the specified expression.
Control the injection location by passing a visibility expression to the AddVirtualSubTree
methods on the root UIBuilderConfigBuilder
instance. Without a visibility expression, the subtree appears under every node in the target tree. This expression can be used to identify the exact location where the tree should go.
The visibility expression receives a VirtualSubTreeFilterContext
argument with relevant contextual information. The information includes the current node being rendered, alongside a list of the current user's user groups for permission-based visibility control. It also includes access to an IServiceProvider
for dependency resolution.
The position of a virtual subtree within the child nodes of the injection node is controlled by using one of the AddVirtualSubTreeBefore
or AddVirtualSubTreeAfter
methods. These methods need to be on the root level UIBuilderConfigBuilder
instance. The match expression identifies the node for insertion. This expression passes a single TreeNode
argument to determine the position. It also requires a boolean
return value to indicate the relevant location has been found.
Below you can find an example of positioning a subtree after a node with the alias "settings":
Virtual subtrees use the Tree
config builder API including support for folders and collections. There is an exception when adding collections to a subtree where you will have an additional foreign key expression parameter to define. The foreign key expression links the entities of the collection to the parent node of the subtree. For more information, see the article.
Out of the box, Umbraco UI Builder supports injecting subtrees into the core content, media, members, and member group trees. It also includes third-party support for settings and commerce trees. To inject into additional trees, implement an ITreeHelper
to extract necessary data. The tree helper consists of a tree alias for which the tree helper is. It includes methods to correctly identify the full parent path, a unique ID for a given node ID, and to resolve the actual entity ID. The entity ID should be used for the foreign key collection values.
Once you have defined a tree helper, register the DI container in your startup class.
Once registered, any virtual subtree assigned to the helper’s tree alias will use it to locate required data.
AddSection(string name, Lambda sectionConfig = null) : SectionConfigBuilder
config.AddSection("Repositories", sectionConfig => {
...
});
AddSectionBefore(string beforeAlias, string name, Lambda sectionConfig = null) : SectionConfigBuilder
config.AddSectionBefore("settings", "Repositories", sectionConfig => {
...
});
AddSectionAfter(string afterAlias, string name, Lambda sectionConfig = null) : SectionConfigBuilder
config.AddSectionAfter("media", "Repositories", sectionConfig => {
...
});
SetAlias(string alias) : SectionConfigBuilder
sectionConfig.SetAlias("repositories");
Tree(Lambda treeConfig = null) : TreeConfigBuilder
sectionConfig.Tree(treeConfig => {
...
});
AddDashboard(string name, Lambda dashboardConfig = null) : DashboardConfigBuilder
sectionConfig.AddDashboard("Team", dashboardConfig => {
...
});
AddDashboardBefore(string beforeAlias, string name, Lambda dashboardConfig = null) : DashboardConfigBuilder
sectionConfig.AddDashboardBefore("contentIntro", "Team", dashboardConfig => {
...
});
AddDashboardAfter(string afterAlias, string name, Lambda dashboardConfig = null) : DashboardConfigBuilder
sectionConfig.AddDashboardAfter("contentIntro", "Team", dashboardConfig => {
...
});
WithSection(string alias, Lambda sectionConfig = null) : WithSectionConfigBuilder
config.WithSection("member", withSectionConfig => {
...
});
AddTree(string name, string icon, Lambda treeConfig = null) : TreeConfigBuilder
withSectionConfig.AddTree("My Tree", "icon-folder", treeConfig => {
...
});
AddTree(string groupName, string name, string icon, Lambda treeConfig = null) : TreeConfigBuilder
withSectionConfig.AddTree("My Group", "My Tree", "icon-folder", treeConfig => {
...
});
AddTreeBefore(string treeAlias, string name, string icon, Lambda treeConfig = null) : TreeConfigBuilder
withSectionConfig.AddTreeBefore("member", "My Tree", "icon-folder", treeConfig => {
...
});
AddTreeAfter(string treeAlias, string name, string icon, Lambda treeConfig = null) : TreeConfigBuilder
withSectionConfig.AddTreeAfter("member", "My Tree", "icon-folder", treeConfig => {
...
});
AddDashboard (string name, Lambda dashboardConfig = null) : DashboardConfigBuilder
withSectionConfig.AddDashboard("Team", dashboardConfig => {
...
});
AddDashboardBefore (string beforeAlias, string name, Lambda dashboardConfig = null) : DashboardConfigBuilder
withSectionConfig.AddDashboardBefore("contentIntro", "Team", dashboardConfig => {
...
});
AddDashboardAfter (string afterAlias, string name, Lambda dashboardConfig = null) : DashboardConfigBuilder
withSectionConfig.AddDashboardAfter("contentIntro", "Team", dashboardConfig => {
...
});
AddVirtualSubTree(string sectionAlias, string treeAlias, Lambda visibilityExpression, Lambda virtualSubTreeConfig = null) : VirtualSubTreeConfigBuilder
withTreeConfig.AddVirtualSubTree(ctx => ctx.Source.Id == 1056, contextAppConfig => {
...
});
AddVirtualSubTreeBefore(string sectionAlias, string treeAlias, Lambda visibilityExpression, Lambda matchExpression, Lambda virtualSubTreeConfig = null) : VirtualSubTreeConfigBuilder
withTreeConfig.AddVirtualSubTreeBefore(ctx => ctx.Source.Id == 1056, treeNode => treeNode.Name == "Settings", contextAppConfig => {
...
});
AddVirtualSubTreeAfter(string sectionAlias, string treeAlias, Lambda visibilityExpression, Lambda matchExpression, Lambda virtualSubTreeConfig = null) : VirtualSubTreeConfigBuilder
withTreeConfig.AddVirtualSubTreeAfter(ctx => ctx.Source.Id == 1056, treeNode => treeNode.Name == "Settings", contextAppConfig => {
...
});
public class VirtualSubTreeFilterContext
{
public NodeContext Source { get; }
public IEnumerable<IReadOnlyUserGroup> UserGroups { get; }
public IServiceProvider ServiceProvider { get; }
}
public class NodeContext
{
public string Id { get; }
public string TreeAlias { get; }
public string SectionAlias { get; }
public FormCollection QueryString { get; }
}
withTreeConfig.AddVirtualSubTree(ctx =>
{
using var umbracoContextRef = ctx.ServiceProvider.GetRequiredService<IUmbracoContextFactory>().EnsureUmbracoContext();
if (!int.TryParse(ctx.Source.Id, out int id))
return false;
return (umbracoContextRef.UmbracoContext.Content.GetById(id)?.ContentType.Alias ?? "") == "textPage";
},
virtualNodeConfig => virtualNodeConfig
...
);
public class TreeNode
{
public object Id { get; }
public object ParentId { get; }
public string Alias { get; }
public string Name { get; }
public string NodeType { get; }
public string Path { get; }
public string RoutePath { get; }
public IDictionary<string, object> AdditionalData { get; }
...
}
treeNode => treeNode.alias == "settings"
public interface ITreeHelper
{
string TreeAlias { get; }
string GetUniqueId(string nodeId, FormCollection queryString);
object GetEntityId(string uniqueId);
string GetPath(string uniqueId);
}
builder.Services.AddSingleton<ITreeHelper, MyCustomTreeHelper>();
Configuring Many-to-Many Relationships in Umbraco UI Builder
This page is a work in progress and may undergo further revisions, updates, or amendments. The information contained herein is subject to change without notice.
Related collections support the editing of many-to-many relationships in UI Builder. These are used when multiple entities from one collection are linked to multiple entities from another collection, commonly represented through a junction table.
A classic example is the relationship between Students
and Courses
, where each student takes many courses, and each course has many students.
This is how the collections would be represented:
The models representing the entities would be as follows:
[TableName("Students")]
[PrimaryKey("Id")]
public class Student
{
[PrimaryKeyColumn]
public int Id { get; set; }
public string FirstName { get; set; }
public string LastName { get; set; }
public string Email { get; set; }
}
[TableName("Courses")]
[PrimaryKey("Id")]
public class Course
{
[PrimaryKeyColumn]
public int Id { get; set; }
public string Title { get; set; }
public string Description { get; set; }
}
[TableName("StudentsCourses")]
[PrimaryKey(new[] { "StudentId", "CourseId" })]
public class StudentCourse
{
[PrimaryKeyColumn]
public int StudentId { get; set; }
[PrimaryKeyColumn]
public int CourseId { get; set; }
}
To define a related collection, follow these two steps:
Add the collection definition
Add the related collection entity picker and definition
Define a related collection by calling the AddRelatedCollection
method on the collection config builder instance.
AddRelatedCollection()
MethodThis method adds a related collection to the current collection, specifying names, descriptions, and default icons. The ID property must be defined, and the relation configuration defines the junction entity with references to parent and child entities.
AddRelatedCollection<TEntityType, TRelatedEntityType, TJunctionEntityType>(Expression<Func<TRelatedEntityType, object>> idPropertyExpression, string nameSingular, string namePlural, Action<RelationConfigBuilder<TBuilder, TEntity, TRelatedEntityType, TJunctionEntityType>> relationConfig)
collectionConfig.AddRelatedCollection<Student, Course, StudentCourse>(x => x.Id, "Student Course", "Students Courses", relationConfig =>
{
relationConfig
.SetAlias("studentsCourses")
.SetJunction<StudentCourse>(x => x.StudentId, y => y.CourseId);
});
Define the child collection entity picker by calling the AddRelatedCollectionPickerField
method on the parent collection's fieldset config.
AddRelatedCollectionPickerField()
MethodThis method adds an entity picker with the specified Data Type name to the parent collection editor.
AddRelatedCollectionPickerField<TValueType>(string alias, string dataTypeName, string label)
collectionConfig.Editor(editorConfig =>
{
editorConfig.AddTab("General", tabConfig =>
tabConfig.AddFieldset("General", fieldsetConfig =>
{
fieldsetConfig.AddField(x => x.FirstName).MakeRequired();
fieldsetConfig.AddField(x => x.LastName).MakeRequired();
fieldsetConfig.AddField(x => x.Email).MakeRequired();
fieldsetConfig.AddRelatedCollectionPickerField<Course>("studentsCourses", "Courses Related Picker", "Courses");
}));
});
GetRelationsByParentIdImpl<>()
MethodRetrieves related collections based on the ID of the parent entity.
IEnumerable<StudentCourse> GetRelationsByParentIdImpl<StudentCourse>(int parentId, string relationAlias)
{
var db = _scopeProvider.CreateScope().Database;
var sql = db.SqlContext.Sql()
.Select(new[] { "StudentId", "CourseId" } )
.From("StudentsCourses")
.Where($"studentId = @0", parentId);
var result = db.Fetch<StudentCourse>(sql);
return result;
}
SaveRelationImpl<>()
MethodAdds a new related collection to the current parent entity.
StudentCourse SaveRelationImpl<StudentCourse>(StudentCourse entity)
{
var db = _scopeProvider.CreateScope().Database;
var type = entity.GetType();
var studentId = type.GetProperty("StudentId").GetValue(entity);
var courseId = type.GetProperty("CourseId").GetValue(entity);
// delete relation if exists
db.Execute("DELETE FROM StudentsCourses WHERE StudentId = @0 AND CourseId = @1",
studentId,
courseId);
db.Execute("INSERT INTO StudentsCourses (StudentId, CourseId) VALUES (@0, @1)",
studentId,
courseId);
return entity;
}
Configuring context apps in Umbraco UI Builder.
Context Apps in Umbraco UI Builder function similarly to Workspace Views (previously called as Content Apps). They provide contextual applications within the content editor UI. By defining context apps, you can expose collections that are directly related to the content in question. For example, blog post comments can be linked to their respective blog posts and managed in context through a Workspace View.
You can define a context app by calling one of the AddContextApp
methods on a WithTreeConfigBuilder
instance.
AddContextApp()
MethodAdds a context app with the specified name and default icon.
AddContextApp(string name, Lambda contextAppConfig = null) : ContextAppConfigBuilder
withTreeConfig.AddContextApp("Comments", contextAppConfig => {
...
});
AddContextApp()
Method with Custom IconAdds a context app with the specified name and custom icon.
AddContextApp(string name, string icon, Lambda contextAppConfig = null) : ContextAppConfigBuilder
withTreeConfig.AddContextApp("Comments", "icon-chat", contextAppConfig => {
...
});
AddContextAppBefore()
MethodAdds a context app with the specified name and default icon before another context app specified by its alias.
AddContextAppBefore(string beforeAlias, string name, Lambda contextAppConfig = null) : ContextAppConfigBuilder
withTreeConfig.AddContextAppBefore("umbContent", "Comments", contextAppConfig => {
...
});
AddContextAppBefore()
Method with a Custom IconAdds a context app with the specified name and custom icon before another context app specified by its alias.
AddContextAppBefore(string beforeAlias, string name, string icon, Lambda contextAppConfig = null) : ContextAppConfigBuilder
withTreeConfig.AddContextAppBefore("umbContent", "Comments", "icon-chat", contextAppConfig => {
...
});
AddContextAppAfter()
MethodAdds a context app with the specified name and default icon after another context app specified by its alias.
AddContextAppAfter(string afterAlias, string name, Lambda contextAppConfig = null) : ContextAppConfigBuilder
withTreeConfig.AddContextAppAfter("umbContent", "Comments", contextAppConfig => {
...
});
AddContextAppAfter()
Method with a Custom IconAdds a context app with the specified name and custom icon after another context app specified by its alias.
AddContextAppAfter(string afterAlias, string name, string icon, Lambda contextAppConfig = null) : ContextAppConfigBuilder
withTreeConfig.AddContextAppAfter("umbContent", "Comments", "icon-chat", contextAppConfig => {
...
});
SetAlias()
MethodSets the alias of the context app. By default, an alias is automatically generated from the context app's name. You can use the SetAlias
method to specify a custom alias.
SetAlias(string alias) : ContextAppConfigBuilder
contextAppConfig.SetAlias("comments");
SetIconColor()
MethodSets the context app icon color to the given color. The available colors are: black
, green
, yellow
, orange
, blue
or red
.
SetIconColor(string color) : ContextAppConfigBuilder
contextAppConfig.SetIconColor("blue");
Context app visibility is controlled by a delegate that takes a ContextAppVisibilityContext
instance. This method contains a Source
property which holds a reference to the source object that the Workspace View is being displayed on (i.e., an IContent
instance). It also holds a reference to a UserGroups
collection of the currently logged-in user's user groups. You can use these values to determine when the context app should be displayed.
By default, context apps are pre-filtered to only appear on the tree they are defined in. This default behavior is combined with the SetVisibility configuration to control visibility.
SetIconColor()
MethodDefines the visibility of the context app based on a delegate expression.
SetVisibility(Func<ContextAppVisibilityContext, bool> visibilityExpression) : ContextAppConfigBuilder
contextAppConfig.SetVisibility(appCtx => appCtx.Source is IContent content && content.ContentType.Alias == "blogPost");
Context apps can consist of one or more collections. If a context app contains multiple collections, the collection list views will be displayed in tabs within the context app.
AddCollection<>()
MethodAdds a collection to the current context app with the specified names, descriptions, and default icons. Each collection requires an ID field and a foreign key field, linking to Umbraco node UDI values. For more details, see the Collections article.
AddCollection<TEntityType>(
Lambda idFieldExpression,
Lambda fkFieldExpression,
string nameSingular,
string namePlural,
string description,
Lambda collectionConfig = null
) : ContextAppConfigBuilder
contextAppConfig.AddCollection<Comment>(
p => p.Id,
p => "Comment",
"Comments",
"A collection of comments",
collectionConfig => {
// Collection configuration here
}
);
AddCollection<>()
Method with Custom IconAddCollection<TEntityType>(Lambda idFieldExpression, Lambda fkFieldExpression, string nameSingular, string namePlural, string description, string iconSingular, string iconPlural, Lambda collectionConfig = null) : ContextAppConfigBuilder
Adds a collection to the current context app with the specified names, descriptions, and custom icons. Each collection requires an ID field and a foreign key field, linking to Umbraco node UDI values. For more details, see the Collections article.
AddCollection<TEntityType>(
Lambda idFieldExpression,
Lambda fkFieldExpression,
string nameSingular,
string namePlural,
string description,
string iconSingular,
string iconPlural,
Lambda collectionConfig = null
) : ContextAppConfigBuilder
contextAppConfig.AddCollection<Comment>(
p => p.Id,
"Comment",
"Comments",
"A collection of comments",
"icon-chat",
"icon-chat",
collectionConfig => {
// Collection configuration here
}
);
Configuring the editor of a collection in Umbraco UI Builder.
An editor is the user interface used to edit an entity. It consists of tabs and property editors.
The editor configuration is a sub-configuration of a Collection
config builder instance and is accessed via the Editor
method.
Editor()
MethodAccesses the editor configuration for the specified collection.
Editor(Lambda editorConfig = null) : EditorConfig<TEntityType>
collectionConfig.Editor(editorConfig => {
...
});
AddTab()
MethodAdds a tab to the editor.
AddTab(string name, Lambda tabConfig = null) : EditorTabConfigBuilder<TEntityType>
editorConfig.AddTab("General", tabConfig => {
...
});
A sidebar is a smaller section displayed on the right side of the main editor. It can contain fieldsets and fields, similar to tabs, but with limited space. The sidebar is ideal for displaying entity metadata.
Sidebar()
MethodConfigures the sidebar for the tab.
Sidebar(Lambda sidebarConfig = null) : EditorTabSidebarConfigBuilder<TEntityType>
tabConfig.Sidebar(sidebarConfig => {
...
});
SetVisibility()
Method for TabsDetermines the visibility of the tab at runtime.
SetVisibility(Predicate<EditorTabVisibilityContext> visibilityExpression) : EditorTabConfigBuilder<TEntityType>
tabConfig.SetVisibility(ctx => ctx.EditorMode == EditorMode.Create);
AddFieldset()
MethodAdds a fieldset to a tab.
AddFieldset(string name, Lambda fieldsetConfig = null) : EditorFieldsetConfigBuilder<TEntityType>
tabConfig.AddFieldset("Contact", fieldsetConfig => {
...
});
SetVisibility()
Method for FieldsetsDetermines the visibility of a fieldset at runtime.
SetVisibility(Predicate<EditorFieldsetVisibilityContext> visibilityExpression) : EditorFieldsetConfigBuilder<TEntityType>
fieldsetConfig.SetVisibility(ctx => ctx.EditorMode == EditorMode.Create);
AddField()
MethodAdds a property field to the editor.
AddField(Lambda propertyExpression, Lambda propertyConfig = null) : EditorFieldConfigBuilder<TEntityType, TValueType>
fieldsetConfig.AddField(p => p.FirstName, fieldConfig => {
...
});
By default, Umbraco UI Builder converts property names into readable labels by splitting camel case names. You can override this behavior by setting an explicit label.
SetLabel()
MethodSets a custom label for a field.
SetLabel(string label) : EditorFieldConfigBuilder<TEntityType, TValueType>
fieldConfig.SetLabel("First Name");
Sometimes, a field works better without a label, especially in full-width layouts.
HideLabel()
MethodHides the field label.
HideLabel() : EditorFieldConfigBuilder<TEntityType, TValueType>
fieldConfig.HideLabel();
SetDescription()
MethodAdds a description to the field.
SetDescription(string description) : EditorFieldConfigBuilder<TEntityType, TValueType>
fieldConfig.SetDescription("Enter your age in years");
By default, Umbraco UI Builder assigns a suitable Data Type for basic field types. However, you can specify a custom Data Type.
SetDataType()
MethodAssigns an Umbraco Data Type by name or ID.
SetDataType(string dataTypeName) : EditorFieldConfigBuilder<TEntityType, TValueType>
fieldConfig.SetDataType("Richtext Editor");
SetDataType(int dataTypeId) : EditorFieldConfigBuilder<TEntityType, TValueType>
fieldConfig.SetDataType(-88);
SetDefaultValue()
MethodSets a static default value.
SetDefaultValue(TValueType defaultValue) : EditorFieldConfigBuilder<TEntityType, TValueType>
// Example
fieldConfig.SetDefaultValue(10);
SetDefaultValue()
Method (Function-Based)Defines a function to compute the default value at the time of entity creation.
SetDefaultValue(Func defaultValueFunc) : EditorFieldConfigBuilder<TEntityType, TValueType>
fieldConfig.SetDefaultValue(() => DateTime.Now);
MakeRequired()
MethodMarks a field as required.
MakeRequired() : EditorFieldConfigBuilder<TEntityType, TValueType>
fieldConfig.MakeRequired();
SetValidationRegex()
MethodApplies a regular expression for field validation.
SetValidationRegex(string regex) : EditorFieldConfigBuilder<TEntityType, TValueType>
fieldConfig.SetValidationRegex("[A-Z0-9._%+-]+@[A-Z0-9.-]+\\.[A-Z]{2,4}");
MakeReadOnly()
MethodThis method makes the current field read-only, preventing any user modifications in the UI. Once applied, the field's value remains visible but cannot be edited.
MakeReadOnly() : EditorFieldConfigBuilder<TEntityType, TValueType>
fieldConfig.MakeReadOnly();
MakeReadOnly(Func<TValueType, string>)
MethodThis method makes the current field read-only, preventing user edits in the UI. Additionally, it allows specifying a custom formatting expression, which determines how the field value is displayed as a string.
MakeReadOnly(Func<TValueType, string> format) : EditorFieldConfigBuilder<TEntityType, TValueType>
fieldConfig.MakeReadOnly(distanceProp => $"{distanceProp:## 'km'}");
MakeReadOnly(object dataTypeNameOrId)
MethodThis method makes the current field read-only, preventing user edits in the UI. Additionally, it allows specifying a Data Type name or ID to determine how the field should be rendered when in read-only mode.
MakeReadOnly(object dataTypeNameOrId) : EditorFieldConfigBuilder<TEntityType, TValueType>
fieldConfig.MakeReadOnly("myReadOnlyEditor");
MakeReadOnly(Predicate<>)
MethodThis method makes the current field read-only in the UI if the provided runtime predicate evaluates to true, preventing user edits.
MakeReadOnly(Predicate<EditorFieldReadOnlyContext> readOnlyExp) : EditorFieldConfigBuilder<TEntityType, TValueType>
fieldConfig.MakeReadOnly(ctx => ctx.EditorMode == EditorMode.Create);
MakeReadOnly(Predicate<>, Func<>)
MethodThis method makes the current field read-only in the UI if the provided runtime predicate evaluates to true, preventing user edits. It also allows specifying a custom formatting expression to render the field’s value as a string.
MakeReadOnly(Predicate<EditorFieldReadOnlyContext> readOnlyExp, Func<TValueType, string> format) : EditorFieldConfigBuilder<TEntityType, TValueType>
fieldConfig.MakeReadOnly(ctx => ctx.EditorMode == EditorMode.Create, distanceProp => $"{distanceProp:## 'km'}");
MakeReadOnly(Predicate<>, Func<>)
MethodThis method makes the current field read-only in the UI if the provided runtime predicate evaluates to true, preventing user edits. It also allows specifying a Data Type name or ID to use when the field is in read-only mode.
MakeReadOnly(Predicate<EditorFieldReadOnlyContext> readOnlyExp, object dataTypeNameOrId) : EditorFieldConfigBuilder<TEntityType, TValueType>
fieldConfig.MakeReadOnly(ctx => ctx.EditorMode == EditorMode.Create, "myReadOnlyEditor");
SetVisibility()
Method for FieldsControls field visibility at runtime.
SetVisibility(Predicate<EditorFieldVisibilityContext> visibilityExpression) : EditorFieldConfigBuilder<TEntityType, TValueType>
fieldConfig.SetVisibility(ctx => ctx.EditorMode == EditorMode.Create);
Configuring and customizing Trees to organize and manage the backoffice interface effectively.
A tree is a hierarchical structure that organizes sections into sub-sections. It appears in the main side panel of the Umbraco interface. In Umbraco UI Builder, each section can only have one tree definition, but you can use folder nodes to organize the tree.
The tree configuration for Umbraco UI Builder sections is part of the config builder and is accessed via its Tree
method.
Tree()
MethodThis method defines the structure and behavior of a tree within a section.
To add a tree to an existing section, use one of the AddTree
methods from the config builder.
AddTree()
methodThis method adds a tree to the current section, specifying its name and icon.
AddTree()
MethodThis method adds a tree to the current section under a specified group.
AddTreeBefore()
to Position a TreeThis method adds a tree to the current section before the tree with the specified alias.
AddTreeAfter()
to Position a TreeThis method adds a tree to the current section after the tree with the specified alias.
SetIconColor()
MethodThis method changes the color of the tree’s icon. The available options are black
, green
, yellow
, orange
, blue
, or red
.
Only trees in existing sections have an icon. Trees in Umbraco UI Builder sections display the tree contents directly.
AddGroup()
MethodThis method adds a group to the current tree with the specified name.
Only trees in Umbraco UI Builder sections support groups.
AddFolder()
MethodThis method adds a folder node inside a tree or group, using the default folder icon. For more details, see the article.
AddFolder()
Method with Custom IconThis method adds a folder with a specified icon inside a tree or group. For more details, see the article.
AddCollection<>()
MethodThis method adds a collection to the current tree or group, specifying its names, descriptions, and default icons. The ID property must be defined. For more details, see the article.
AddCollection<>()
Method with IconsThis method adds a collection to the current tree or group, specifying its names, descriptions, and custom icons. The ID property must be defined. For more details, see the article.
To extend existing trees, call the WithTree
method on a instance.
WithTree()
MethodThis method starts a sub-configuration for an existing tree with the specified alias.
AddContextApp()
MethodThis method adds a context app with the specified name and default icon. For more details, see the article.
AddContextApp()
Method with Custom IconThis method adds a context app with the specified name and custom icon. For more details, see the article.
AddContextApp()
Method Before Another Context AppThis method adds a context app with the specified name and default icon before the specified context app alias. For more information, see the article.
AddContextApp()
Method with Custom Icon Before Another Context AppThis method adds a context app with the specified name and custom icon before the specified context app alias. For more information, see the article.
AddContextApp()
Method After Another Context AppThis method adds a context app with the specified name and default icon after the specified context app alias. For more information, see the article.
AddContextApp()
Method with Custom Icon After Another Context AppThis method adds a context app with the specified name and custom icon after the specified context app alias. For more information, see the article.
Tree(Lambda treeConfig = null) : TreeConfigBuilder
sectionConfig.Tree(treeConfig => {
...
});
AddTree(string name, string icon, Lambda treeConfig = null) : TreeConfigBuilder
withSectionConfig.AddTree("My Tree", "icon-folder", treeConfig => {
...
});
AddTree(string groupName, string name, string icon, Lambda treeConfig = null) : TreeConfigBuilder
withSectionConfig.AddTree("My Group", "My Tree", "icon-folder", treeConfig => {
...
});
AddTreeBefore(string treeAlias, string name, string icon, Lambda treeConfig = null) : TreeConfigBuilder
withSectionConfig.AddTreeBefore("member", "My Tree", "icon-folder", treeConfig => {
...
});
AddTreeAfter(string treeAlias, string name, string icon, Lambda treeConfig = null) : TreeConfigBuilder
withSectionConfig.AddTreeAfter("member", "My Tree", "icon-folder", treeConfig => {
...
});
SetIconColor(string color) : TreeConfigBuilder
collectionConfig.SetIconColor("blue");
AddGroup(string name, Lambda groupConfig = null) : GroupConfigBuilder
treeConfig.AddGroup("Settings", groupConfig => {
...
});
AddFolder(string name, Lambda folderConfig = null) : FolderConfigBuilder
treeConfig.AddFolder("Settings", folderConfig => {
...
});
AddFolder(string name, string icon, Lambda folderConfig = null) : FolderConfigBuilder
treeConfig.AddFolder("Settings", "icon-settings", folderConfig => {
...
});
AddCollection<TEntityType>(
Lambda idFieldExpression,
string nameSingular,
string namePlural,
string description,
Lambda collectionConfig = null
) : CollectionConfigBuilder<TEntityType>
treeConfig.AddCollection<Person>(
p => p.Id,
"Person",
"People",
"A collection of people",
collectionConfig => {
...
}
);
AddCollection<TEntityType>(
Lambda idFieldExpression,
string nameSingular,
string namePlural,
string description,
string iconSingular,
string iconPlural,
Lambda collectionConfig = null
) : CollectionConfigBuilder<TEntityType>
treeConfig.AddCollection<Person>(
p => p.Id,
"Person",
"People",
"A collection of people",
"icon-umb-users",
"icon-umb-users",
collectionConfig => {
...
}
);
WithTree(string alias, Lambda treeConfig = null) : WithTreeConfigBuilder
sectionConfig.WithTree("content", withTreeConfig => {
...
});
AddContextApp(string name, Lambda contextAppConfig = null) : ContextAppConfigBuilder
withTreeConfig.AddContextApp("Comments", contextAppConfig => {
...
});
AddContextApp(string name, string icon, Lambda contextAppConfig = null) : ContextAppConfigBuilder
withTreeConfig.AddContextApp("Comments", "icon-chat", contextAppConfig => {
...
});
AddContextAppBefore(string beforeAlias, string name, Lambda contextAppConfig = null) : ContextAppConfigBuilder
withTreeConfig.AddContextAppBefore("umbContent", "Comments", contextAppConfig => {
...
});
AddContextAppBefore(string beforeAlias, string name, string icon, Lambda contextAppConfig = null) : ContextAppConfigBuilder
withTreeConfig.AddContextAppBefore("umbContent", "Comments", "icon-chat", contextAppConfig => {
...
});
AddContextAppAfter(string afterAlias, string name, Lambda contextAppConfig = null) : ContextAppConfigBuilder
withTreeConfig.AddContextAppAfter("umbContent", "Comments", contextAppConfig => {
...
});
AddContextAppAfter(string afterAlias, string name, string icon, Lambda contextAppConfig = null) : ContextAppConfigBuilder
withTreeConfig.AddContextAppAfter("umbContent", "Comments", "icon-chat", contextAppConfig => {
...
});
An overview of the basics of configuring a collection in Umbraco UI Builder.
A collection configuration in Umbraco UI Builder defines how collections are structured and displayed in the backoffice. This guide covers the core concepts, with additional options available in other configuration sections.
A collection is defined using the AddCollection
method on a Tree
or parent Folder
configuration instance.
AddCollection()
MethodAdds a collection to the given container with the specified names, description, and default icons. The ID property must be defined.
AddCollection<TEntityType>(Lambda idFieldExpression, string nameSingular, string namePlural, string description, Lambda collectionConfig = null) : CollectionConfigBuilder<TEntityType>
folderConfig.AddCollection<Person>(p => p.Id, "Person", "People", "A collection of people", collectionConfig => {
...
});
AddCollection()
Method with IconsAdds a collection to the given container with the specified names, description, and icons. The ID property must be defined.
AddCollection<TEntityType>(Lambda idFieldExpression, string nameSingular, string namePlural, string description, string iconSingular, string iconPlural, Lambda collectionConfig = null) : CollectionConfigBuilder<TEntityType>
folderConfig.AddCollection<Person>(p => p.Id, "Person", "People", "A collection of people", "icon-umb-users", "icon-umb-users", collectionConfig => {
...
});
SetAlias()
MethodSets the alias of the collection.
Optional: When creating a new collection, an alias is automatically generated from the supplied name for you. To customize the alias, the SetAlias
method can be used.
SetAlias(string alias) : CollectionConfigBuilder<TEntityType>
collectionConfig.SetAlias("person");
SetIconColor()
MethodSets the collection icon color to the given color. The available options are black
, green
, yellow
, orange
, blue
, or red
.
SetIconColor(string color) : CollectionConfigBuilder<TEntityType>
collectionConfig.SetIconColor("blue");
In Umbraco, every entity is expected to have a name property. To ensure the Umbraco UI Builder knows which property to use, you must specify it.
If the entity lacks a dedicated name property, you can define how to construct a name using other properties. This is done using either the SetNameProperty
or SetNameFormat
methods on a Collection
config builder instance.
SetNameProperty()
MethodSpecifies the entity property to use as the name, which must be of type string
. This property serves as the label in trees and list views, appears in the editor interface header, and is automatically included in searchable properties. It is also used as the default sorting property.
SetNameProperty(Lambda namePropertyExpression) : CollectionConfigBuilder<TEntityType>
collectionConfig.SetNameProperty(p => p.Name);
SetNameProperty()
Method with Custom HeadingSpecifies which property of your entity should be used as the name property and defines a custom heading for the list view column. The property must be of type string
.
Setting a name property ensures its value is displayed as the label for the entity in trees and list views. It will also be editable in the editor interface's header region.
Additionally, the property is automatically added to the searchable properties collection and used as the default sort property.
SetNameProperty(Lambda namePropertyExpression, string heading) : CollectionConfigBuilder<TEntityType>
collectionConfig.SetNameProperty(p => p.Name, "Person Name");
SetNameFormat()
MethodDefines a format expression to dynamically generate a label for the entity in trees and list views.
This method is used when there is no single name property available on the entity. As a result, none of the default behaviors of the SetNameProperty
method, such as automatic sorting, searching, or header editing, will apply.
SetNameFormat(Lambda nameFormatExpression) : CollectionConfigBuilder<TEntityType>
collectionConfig.SetNameFormat(p => $"{p.FirstName} {p.LastName}");
SetSortProperty()
MethodSpecifies the property used to sort the collection, with the default sort direction set to ascending.
SetSortProperty(Lambda sortPropertyExpression) : CollectionConfigBuilder<TEntityType>
collectionConfig.SetSortProperty(p => p.FirstName);
SetSortProperty()
Method with Sort DirectionDefines the property of the entity to sort by, based on the specified sort direction.
SetSortProperty(Lambda sortPropertyExpression, SortDirection sortDirection) : CollectionConfigBuilder<TEntityType>
collectionConfig.SetSortProperty(p => p.FirstName, SortDirection.Descending);
SetDateCreatedProperty
MethodDefines the property of the entity to use as the date created field. The property must be of type DateTime
. When specified, this field will be automatically populated with the current date and time when a new entity is saved via the repository.
SetDateCreatedProperty(Lambda dateCreatedProperty) : CollectionConfigBuilder<TEntityType>
collectionConfig.SetDateCreatedProperty(p => p.DateCreated);
SetDateModifiedProperty
MethodDefines the property of the entity to use as the date modified field. The property must be of type DateTime
. When specified, this field will be updated with the current date and time whenever the entity is saved via the repository.
SetDateModifiedProperty(Lambda dateCreatedProperty) : CollectionConfigBuilder<TEntityType>
collectionConfig.SetDateModifiedProperty(p => p.DateModified);
By default, entities deleted via the Umbraco UI Builder repository are permanently removed from the system. The SetDeletedProperty
method marks records as deleted without removing them. This retains them in the data repository while hiding them from the UI.
SetDeletedProperty()
MethodDefines the property of the entity to use as the deleted flag. The property must be of type boolean
or int
. When set, delete actions will mark the entity as deleted by setting the flag instead of removing the entity.
For boolean
properties, the flag is set to True
when deleted. For int
properties, the flag is set to a UTC Unix timestamp representing the deletion date. Additionally, fetch actions will automatically exclude deleted entities.
SetDeletedProperty(Lambda deletedPropertyExpression) : CollectionConfigBuilder<TEntityType>
collectionConfig.SetDeletedProperty(p => p.Deleted);
DisableCreate()
MethodDisables the option to create entities within the current collection. Entities can still be created programmatically, after which editing is allowed through the UI.
DisableCreate() : CollectionConfigBuilder<TEntityType>
collectionConfig.DisableCreate();
DisableCreate()
Method with ConditionsDisables entity creation within the current collection if the specified runtime predicate evaluates to true. Entities can still be created programmatically, after which editing is allowed in the UI.
DisableCreate(Predicate<CollectionPermissionContext> disableExpression) : CollectionConfigBuilder<TEntityType>
collectionConfig.DisableCreate(ctx => ctx.UserGroups.Any(x => x.Alias == "editor"));
DisableUpdate()
MethodDisables the option to update entities within the current collection. Entities can be created, but further editing is not permitted
DisableUpdate() : CollectionConfigBuilder<TEntityType>
collectionConfig.DisableUpdate();
DisableUpdate()
Method with ConditionsDisables the option to update entities within the current collection if the specified runtime predicate evaluates to true. Entities can be created, but further editing is not permitted.
DisableUpdate(Predicate<CollectionPermissionContext> disableExpression) : CollectionConfigBuilder<TEntityType>
collectionConfig.DisableUpdate(ctx => ctx.UserGroups.Any(x => x.Alias == "editor"));
DisableDelete()
MethodDisables the option to delete entities within the current collection. This is useful when data needs to be retained and visible. For more information, see the Configuring Soft Deletes section.
DisableDelete() : CollectionConfigBuilder<TEntityType>
collectionConfig.DisableDelete();
DisableDelete()
Method with ConditionsDisables the option to delete entities within the current collection if the specified runtime predicate evaluates to true. This is useful when data needs to be retained and visible. For more information, see the Configuring Soft Deletes section.
DisableDelete(Predicate<CollectionPermissionContext> disableExpression) : CollectionConfigBuilder<TEntityType>
collectionConfig.DisableDelete(ctx => ctx.UserGroups.Any(x => x.Alias == "editor"));
MakeReadOnly()
MethodMarks the collection as read-only, disabling all Create, Read, Update, and Delete (CRUD) operations via the UI.
MakeReadOnly() : CollectionConfigBuilder<TEntityType>
collectionConfig.MakeReadOnly();
MakeReadOnly()
Method with ConditionsMarks the collection as read-only if the specified runtime predicate evaluates to true. This disables all Create, Read, Update, and Delete (CRUD) operations via the UI.
MakeReadOnly(Predicate<CollectionPermissionContext> disableExpression) : CollectionConfigBuilder<TEntityType>
collectionConfig.MakeReadOnly(ctx => ctx.UserGroups.Any(x => x.Alias == "editor"));
SetVisibility()
MethodSets the runtime visibility of the collection.
SetVisibility(Predicate<CollectionVisibilityContext> visibilityExpression) : CollectionConfigBuilder<TEntityType>
collectionConfig.SetVisibility(ctx => ctx.UserRoles.Any(x => x.Alias == "editor"));
By default, Umbraco UI Builder uses the Umbraco connection string for its database connection. You can override this by calling the SetConnectionString
method on a Collection
config builder instance.
SetConnectionString()
MethodDefines the connection string for the collection repository.
SetConnectionString(string connectionStringName) : CollectionConfigBuilder<TEntityType>
collectionConfig.SetConnectionString("myConnectionStringName");
Creating your first integration with Umbraco UI Builder.
This guide walks you through a basic implementation of Umbraco UI Builder to manage a custom database table.
Umbraco UI Builder uses PetaPoco as its default persistence layer.
In this section, you will create a Person
table to store data.
To create a Person
table, run the following script in SQL Server Management Studio (SSMS).
CREATE TABLE [Person] (
[Id] int IDENTITY (1,1) NOT NULL,
[Name] nvarchar(255) NOT NULL,
[JobTitle] nvarchar(255) NOT NULL,
[Email] nvarchar(255) NOT NULL,
[Telephone] nvarchar(255) NOT NULL,
[Age] int NOT NULL,
[Avatar] nvarchar(255) NOT NULL
);
This script creates a table for storing people’s details. You may want to populate it with some dummy data for testing.
With the database table created, define the Person
model in your project.
To create a Model:
Create a new folder called Models in your project.
Add a new class file called Person.cs
.
Add the following code:
using NPoco;
using Umbraco.Cms.Infrastructure.Persistence.DatabaseAnnotations;
[TableName("Person")]
[PrimaryKey("Id")]
public class Person
{
[PrimaryKeyColumn]
public int Id { get; set; }
public string? Name { get; set; }
public string? JobTitle { get; set; }
public string? Email { get; set; }
public string? Telephone { get; set; }
public int Age { get; set; }
public string? Avatar { get; set; }
}
With the database and model set up, it is time to configure Umbraco UI Builder to work with the Person
model. This will allow you to manage Person
entities from the Umbraco backoffice.
The following steps cover the Program.cs
approach. For more details, including configuring via a Composer, see the the Configuration article.
Program.cs
Open the Program.cs
file in your project.
Locate the CreateUmbracoBuilder()
method.
Add AddUIBuilder
before AddComposers()
.
builder.CreateUmbracoBuilder()
.AddBackOffice()
.AddWebsite()
.AddDeliveryApi()
.AddComposers()
.AddUIBuilder(cfg => {
// Apply your configuration here
})
.Build();
Here’s an example configuration defining a section, a list view, and an editor for managing Person
entities:
...
.AddUIBuilder(cfg => {
cfg.AddSectionAfter("media", "Repositories", sectionConfig => sectionConfig
.Tree(treeConfig => treeConfig
.AddCollection<Person>(x => x.Id, "Person", "People", "A person entity", "icon-umb-users", "icon-umb-users", collectionConfig => collectionConfig
.SetNameProperty(p => p.Name)
.ListView(listViewConfig => listViewConfig
.AddField(p => p.JobTitle).SetHeading("Job Title")
.AddField(p => p.Email)
)
.Editor(editorConfig => editorConfig
.AddTab("General", tabConfig => tabConfig
.AddFieldset("General", fieldsetConfig => fieldsetConfig
.AddField(p => p.JobTitle).MakeRequired()
.AddField(p => p.Age)
.AddField(p => p.Email).SetValidationRegex("[a-zA-Z0-9_.+-]+@[a-zA-Z0-9-]+.[a-zA-Z0-9-.]+")
.AddField(p => p.Telephone).SetDescription("inc area code")
)
.AddFieldset("Media", fieldsetConfig => fieldsetConfig
.AddField(p => p.Avatar).SetDataType("Upload File")
)
)
)
)
)
);
})
...
After defining the configuration, compile and run your project. To access the newly defined section, you need to give permission to the backoffice user account:
Login to the Umbraco backoffice.
Go to the Users section.
Navigate to the user group you wish to assign the newly defined section.
Submit the changes.
Refresh the browser to view the new section.
If you click on a person's name, you will see the following screen:
This setup allows you to extend and customize your Umbraco site by managing data and entities directly in the backoffice. The simplicity of the implementation allows to create dynamic, user-friendly interfaces for your own data models.