Content Alignment
By default, Grid cell content is left-aligned.
The alignment methods in this article apply to cells generated from the column definitions. If you use a ClientRowTemplate(), the template defines the <tr> and <td> markup, so apply the alignment class or style directly to the relevant <td> elements in the template.
Cell Content
To change the content alignment of the Grid, use either of the following approaches:
-
Apply a
text-alignstyle to the column definition by using theHtmlAttributes()method.Razor.Columns(columns => { columns.Bound(o => o.OrderID).HtmlAttributes(new { style = "text-align: right" }); }) -
Apply the
k-text-left,k-text-right, ork-text-centerclasses to the column definition by using theHtmlAttributes()method.Razor.Columns(columns => { columns.Bound(o => o.OrderID).HtmlAttributes(new { @class = "k-text-right" }); })
Column Headers
Set the alignment of the column headers through the HeaderHtmlAttributes() method.
.Columns(columns =>
{
columns.Bound(o => o.OrderID).HeaderHtmlAttributes(new { style = "text-align: right; justify-content: flex-end;" });
})Column Footers
When a column has a footer, change the alignment of its content by using the FooterHtmlAttributes() method.
.Columns(columns =>
{
columns.Bound(o => o.OrderID).FooterHtmlAttributes(new { style = "text-align: center" });
})