Umbraco UI Builder
CMSCloudHeartcoreDXP
16.latest
16.latest
  • Umbraco UI Builder Documentation
  • Known Issues
  • Release Notes
  • Getting Started
    • Requirements
    • Installing Umbraco UI Builder
    • Licensing
    • Configuration
    • User Interface
  • Upgrading
    • Upgrading Umbraco UI Builder
    • Version Specific Upgrade Notes
    • Migrate from Konstrukt to Umbraco UI Builder
  • How-to Guides
    • Creating your First Integration
  • Areas
    • Overview
    • Sections
      • Summary Dashboards
    • Trees
      • Folders
    • Dashboards
    • Context Apps
  • Collections
    • Overview
    • The Basics
    • List Views
      • Field Views
    • Editors
    • Child Collections
      • Child Collection Groups
      • Retrieve Child Collections
    • Related Collections
    • Entity Identifier Converters
  • Searching
    • Overview
    • Searchable Properties
  • Filtering
    • Overview
    • Global Filters
    • Data Views
      • Data Views Builders
    • Filterable Properties
  • Actions
    • Overview
    • The Basics
    • Action Visibility
    • Inbuilt Actions
  • Cards
    • Overview
    • Count Cards
    • Custom Cards
  • Property Editors
    • Overview
    • Entity Picker
  • Advanced
    • Virtual Sub Trees
    • Encrypted Properties
    • Value Mappers
    • Repositories
    • Events
  • Miscellaneous
    • Conventions
    • Umbraco Aliases
Powered by GitBook
On this page
  • Defining a Field View
  • Basic View File for the Built-In FieldView View Component
  • Custom View Component
  • The Field View Context
  • Setting the Field View of a List View Field

Was this helpful?

Edit on GitHub
Export as PDF
  1. Collections
  2. List Views

Field Views

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.

Defining a Field View

You can define a field view in one of two ways:

Basic View File for the Built-In FieldView View Component

For 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.

Custom View Component

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);
    }
}

The FieldViewContext parameter in the InvokeAsync method must be named context.

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 -->

The Field View Context

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; }
}

Setting the Field View of a List View Field

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.

PreviousList ViewsNextEditors

Last updated 2 months ago

Was this helpful?