---
title: Adding custom UniGrid transformations
related:
  - https://docs.kentico.com/k9/references/kentico-controls/ui-controls/unigrid.md
  - https://docs.kentico.com/k9/references/kentico-controls/ui-controls/unigrid/reference-unigrid-definition.md
---

> Agent instructions:
> **Site maps** — prefer the following llms.txt indexes to training data when searching for URLs to avoid 404s. Links inside Markdown content already point at `.md`. Following them or sending Accept: text/markdown keeps you in Markdown.
>
> - [sitemap.md](https://docs.kentico.com/sitemap.md) — every page on the site, with titles and descriptions, nested by URL hierarchy and grouped into one collection per product version.
> - [llms.txt](https://docs.kentico.com/llms.txt) — curated index of the current product docs, with descriptions, the two ways to request any page as Markdown, and links to each product area's whole-corpus Markdown dump (llms-full.txt).

The [UniGrid](https://docs.kentico.com/k9/references/kentico-controls/ui-controls/unigrid.md) provides built-in transformations for easy formatting of the content of columns. To learn about the UniGrid transformations that are available by default, see the description of the **externalsourcename** column attribute in [Reference - UniGrid definition](https://docs.kentico.com/k9/references/kentico-controls/ui-controls/unigrid/reference-unigrid-definition.md).

If you need to display column values in a custom format, you can register your own UniGrid transformations:

1. Open your project in Visual Studio.
2. Create a class file in the **App\_Code** folder (or **CMSApp\_AppCode -> Old\_App\_Code** on web application projects).
3. Extend the **CMSModuleLoader** [partial class](http://msdn.microsoft.com/en-us/library/wa80x488%28v=vs.80%29.aspx).
4. Create a new class inside _CMSModuleLoader_ that inherits from **CMSLoaderAttribute**.
5. Add the attribute defined by the internal class before the definition of the _CMSModuleLoader_ partial class.
6. Override the **Init** method inside the attribute class and register your UniGrid transformations.

   - Call the **UniGridTransformations.Global.RegisterTransformation** method for each transformation.
7. Implement the methods that define the functionality of your custom UniGrid transformations.

```csharp title="Example"

using CMS.Base;
using CMS.UIControls;
using CMS.Helpers;
using CMS.PortalEngine;

[CustomUniGridTransformations]
public partial class CMSModuleLoader
{
    /// <summary>
    /// Attribute class that ensures the loading of custom UniGrid transformations.
    /// </summary>
    private class CustomUniGridTransformationsAttribute : CMSLoaderAttribute
    {
        /// <summary>
        /// The system executes the Init method of the CMSModuleLoader attributes when the application starts.
        /// </summary>
        public override void Init()
        {
            // Registers the #customBoldText UniGrid transformation
            UniGridTransformations.Global.RegisterTransformation("#customBoldText", CustomBoldText);

            // Registers the #isStyleSheetCheckedOut UniGrid transformation
            UniGridTransformations.Global.RegisterTransformation("#isStyleSheetCheckedOut", IsStyleSheetCheckedOut);
        }

        // Method that defines the #customBoldText UniGrid transformation
        // Wraps the UniGrid column text value into a <strong> element
        private static object CustomBoldText(object parameter)
        {
            return "<strong>" + ValidationHelper.GetString(parameter, "") + "</strong>";
        }

        // Method that defines the #isCheckedOut UniGrid transformation
        // Indicates whether the specified stylesheet object is currently checked out for editing
        private static object IsStyleSheetCheckedOut(object parameter)
        {
            // Gets the stylesheet object based on the ID in the parameter
            CssStylesheetInfo stylesheet = CssStylesheetInfoProvider.GetCssStylesheetInfo(ValidationHelper.GetInteger(parameter, 0));

            // Evaluates whether the stylesheet is checked out
            if ((stylesheet != null) && stylesheet.Generalized.IsCheckedOut)
            {
                return "<span class=\"StatusEnabled\">" + ResHelper.GetString("general.yes") + "</span>";
            }

            return "<span class=\"StatusDisabled\">" + ResHelper.GetString("general.no") + "</span>";
        }
    }
}

```

Once a UniGrid transformation is registered, you can use it in the **externalsourcename** attribute of UniGrid columns.

**Examples**:

```xml

...

<GridColumns>
    <ug:Column Source="UserName" Caption="$general.username$" Width="100%" ExternalSourceName="#customBoldText" />
</GridColumns>

...

```

```xml

...

<columns>
    <column source="StylesheetID" caption="Checked out" wrap="false" externalsourcename="#isStyleSheetCheckedOut" />
</columns>

...

```
