Konstrukt
🚨 Konstrukt is now Umbraco UI Builder 🚨
  • Konstrukt Documentation
  • Getting Started
    • Overview
    • Installation
    • Configuration
    • User Interface
  • 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
  • Searching
    • Overview
    • Searchable Properties
  • Filtering
    • Overview
    • Global Filters
    • Data Views
      • Data Views Builders
    • Filterable Properties
  • Actions
    • Overview
    • The Basics
    • Action Visbility
    • Inbuilt Actions
  • Cards
    • Overview
    • Count Cards
    • Custom Cards
  • Property Editors
    • Overview
    • Entity Picker
  • Advanced
    • Virtual Sub Trees
    • Encrypted Properties
    • Value Mappers
    • Repositories
    • Events
  • Extras
    • Conventions
    • Umbraco Aliases
    • Konstrukt vs UI-O-Matic
    • Known Issues
    • Changelog
Powered by GitBook
On this page
  • Defining a custom card
  • Adding a custom card to a collection
Edit on GitHub
  1. Cards

Custom Cards

Configuring custom cards in Konstrukt, the back office UI builder for Umbraco.

Custom cards allow you to perform more complex metric calculations and are defined via a class implementing the KonstruktCard base class.

When Konstrukt resolves a card it will attempt to do so from the global DI container which means you can inject amy dependencies that you require for your card to calculate it's value. If there is no such type defined in the DI container, Konstrukt will then fallback to maually instantiating a new instance of the card.

Defining a custom card

To define a card you create a class that inherits from the base class KonstruktCard and configure it within the constructor like so.

// Example
public class AvgPersonAgeCard : KonstruktCard
{
    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
    }
}

The required configuration options are:

  • Name: The name of the card.

  • Alias: A unique alias for the card.

  • GetValue(object parentId = null): A method to get the cards value.

Additional optional configuration options are:

  • Icon: An icon to display in the card.

  • Color: The color of the card.

  • Suffix: A suffix to display after the card value.

Adding a custom card to a collection

AddCard() : KonstruktCollectionConfigBuilder<TEntityType>

Adds a card of the given type to the collection.

// Example
collectionConfig.AddCard<AvgPersonAgeCard>();

AddCard(Type cardType) : KonstruktCollectionConfigBuilder<TEntityType>

Adds a card of the given type to the collection.

// Example
collectionConfig.AddCard(typeof(AvgPersonAgeCard));
PreviousCount CardsNextOverview

Last updated 3 years ago