# Row Templates

The Kendo UI Grid supports row templates which enable you to place custom content into a Grid row.

When you use a `ClientRowTemplate`, the template defines the complete `<tr>` and `<td>` markup. To center a cell, add a class or an inline `text-align` style directly to the relevant `<td>` element.

```Razor HtmlHelper
    .ClientRowTemplate("<tr data-uid='#=data.uid#'>" +
        "<td class='toppane-input-wrap'>#=data.OrderID#</td>" +
        "<td class='toppane-input-wrap'>#=data.ShipCountry#</td>" +
    "</tr>")
```

```CSS
    .toppane-input-wrap {
        text-align: center;
    }
```

The `toppane-input-wrap` class in this example is a custom application class, not a Kendo UI class. For standard generated Grid cells, use the column alignment options described in the [content alignment article](https://www.telerik.com/aspnet-core-ui/documentation/html-helpers/data-management/grid/columns/cell-alignment).

For runnable examples, refer to:

* [Demo on using the row template of the Grid HtmlHelper for ASP.NET Core](https://demos.telerik.com/aspnet-core/grid/rowtemplate)
* [Demo on using the detail-row template of the Grid HtmlHelper for ASP.NET Core](https://demos.telerik.com/aspnet-core/grid/detailtemplate)
* [Demo on using the toolbar template of the Grid HtmlHelper for ASP.NET Core](https://demos.telerik.com/aspnet-core/grid/toolbar-template)

The following example demonstrates how to use a string row template which generates two columns. The outermost HTML element in the template must be a table row (`<tr>`). That table row must have the `uid` data attribute set to `#= uid #`. The grid uses the `uid` data attribute to determine which data a table row is bound to.

```Razor HtmlHelper
        .ClientRowTemplate("<tr data-uid='#=data.uid#'>" +
            "<td>#=data.OrderID#</td>" +
            "<td><strong>#=ShipCountry #</strong></td>" +
        "</tr>")
```

```Razor TagHelper
    @{
        string rowTemplate = "<tr data-uid='#=data.uid#'>" +
            "<td>#=data.OrderID#</td>" +
            "<td><strong>#=ShipCountry #</strong></td>" +
            "</tr>";
    }
    <kendo-grid name="grid" style="height:430px;"
            row-template="@rowTemplate">
    </kendo-grid>
```

## Use a JavaScript Function as the Row Template

To define the row template as a JavaScript function, register the function name with `ClientRowTemplateHandler()`. The function receives the data item and must return the complete row markup, including the `data-uid` attribute.

```Razor HtmlHelper
@(Html.Kendo().Grid<ProductViewModel>()
    .Name("grid")
    .ClientRowTemplateHandler("rowTemplateFn")
)
```

```JavaScript
function rowTemplateFn(dataItem) {
    return "<tr data-uid='" + dataItem.uid + "'>" +
        "<td>" + kendo.htmlEncode(dataItem.OrderID) + "</td>" +
        "<td>" + kendo.htmlEncode(dataItem.ShipCountry) + "</td>" +
    "</tr>";
}
```

Use `ClientRowTemplate()` for a Kendo template string; use `ClientRowTemplateHandler()` when the row template is a named JavaScript function.

## Frozen Columns

The Grid does not support row templates together with frozen (locked) columns.

![UI for ASP.NET Core A Grid with an applied row template](https://www.telerik.com/aspnet-core-ui/documentation/assets/5cc130de834d86739ba07dbbff6a495a/row-template.png)

## See Also

* [ASP.NET Core DataGrid Homepage](https://www.telerik.com/aspnet-core-ui/grid)

* [Using Row Templates in the Grid HtmlHelper for ASP.NET Core (Demo)](https://demos.telerik.com/aspnet-core/grid/rowtemplate)

* [Using Detail-Row Templates in the Grid HtmlHelper for ASP.NET Core (Demo)](https://demos.telerik.com/aspnet-core/grid/detailtemplate)

* [Using Toolbar Templates in the Grid HtmlHelper for ASP.NET Core (Demo)](https://demos.telerik.com/aspnet-core/grid/toolbar-template)

* [Server-Side API](https://www.telerik.com/aspnet-core-ui/documentation/api/grid)
