# Templates

The PropertyGrid allows you to control the appearance of the items values by using template options.

For more information on the capabilities and syntax of the templates, see the [Using Client Templates](https://www.telerik.com/aspnet-core-ui/documentation/html-helpers/helper-basics/using-client-templates) article. For a runnable example, refer to the [demo on customizing the templates in the PropertyGrid](https://demos.telerik.com/aspnet-core/propertygrid/templates).

The following example demonstrates how to use the `TemplateHandler()` option to customize the value of an item that has child items.

```Razor HtmlHelper
    @(Html.Kendo().PropertyGrid<PropertyViewModel>()
        .Name("propertyGrid")
        .Items(items =>
        {
            items.Add().Field("font").TemplateHandler("fontTemplate")
            .Items(childItems =>
            {
                childItems.Add().Field("fontWeight");
                childItems.Add().Field("fontFamily");
            });
        })
        ... //Additional configuration
    )
```

```Razor TagHelper
    @addTagHelper *, Kendo.Mvc

    <kendo-propertygrid name="propertyGrid">
        <property-grid-items>
            <property-grid-item field="font" template-handler="fontTemplate">
                <property-grid-items>
                    <property-grid-item field="fontWeight">
                    </property-grid-item>
                    <property-grid-item field="fontFamily">
                    </property-grid-item>
                </property-grid-items>
            </property-grid-item>
        </property-grid-items>
      
    </kendo-propertygrid>
```

```JS scripts
    <script>
        function fontTemplate(data) {
            var propertyGridModel = $("#propertyGrid").data('kendoPropertyGrid').model();
            return `<span class="fontWeight">${propertyGridModel.font["fontWeight"]}</span> <span class="fontFamily">${propertyGridModel.font["fontFamily"]}</span>`;
        }
    </script>
```

The following example demonstrates how to create an inline string template by using the `Template()` option.

```Razor HtmlHelper
    @(Html.Kendo().PropertyGrid<PropertyViewModel>()
        .Name("propertyGrid")
        .Items(items =>
        {
            items.Add().Field(f => f.color).Template("<i><span style='color:#=value#'>#=value#</span></i>")
            .Editor(editor => editor
                .DropDownList()
                .BindTo(new string[] { "red", "green", "blue", "purple", "orange" }));
        })
        ... //Additional configuration
    )
```

```Razor TagHelper
    @addTagHelper *, Kendo.Mvc
    @{
        var colors = new string[] { "red", "green", "blue", "purple", "orange" };
    }
    <kendo-propertygrid name="propertyGrid">
        <property-grid-items>
            <property-grid-item field="color" template="<i><span style='color:#=value#'>#=value#</span></i>">
                <dropdownlist-editor bind-to="colors"></dropdownlist-editor>
            </property-grid-item>
        </property-grid-items>
      
    </kendo-propertygrid>
```

## See Also

* [Templates in the PropertyGrid HtmlHelper for ASP.NET Core (Demo)](https://demos.telerik.com/aspnet-core/propertygrid/templates)
* [Using Client Templates](https://www.telerik.com/aspnet-core-ui/documentation/html-helpers/helper-basics/using-client-templates)
