New to Telerik UI for ASP.NET Core? Download free 30-day trial

ASP.NET Core Grid Content Alignment

Loading Demo...
  • EXAMPLE
  • VIEW SOURCE
  • Edit in Telerik REPL
HtmlHelper
TagHelper
Files:
cell_alignment.cshtml
Cell_AlignmentController.cs
OrderViewModel.cs
Cell_Alignment_TagHelper.cshtml

Also available for:

CLIENT-SIDE API SERVER-SIDE API

Description

The Telerik UI for ASP.NET Core Grid enables you to specify the alignment of its cell content in either of the following ways:

  • Through the column definition by using the HtmlAttributes() method—columns.Bound(o => o.ShipCity).HtmlAttributes(new { style = "text-align: right" });.
  • By applying the k-text-left, k-text-right, or k-text-center classes—columns.Bound(o => o.ShipCity).HtmlAttributes(new { @class = "k-text-right" });.
  • Also, you can update the alignment of the column header through the HeaderHtmlAttributes() method—columns.Bound(o => o.ShipCity).HeaderHtmlAttributes(new { style = "text-align: center; justify-content: center" });

    Additionally, the ASP.NET Core Data Grid enables you to align its column footer by using the FooterHtmlAttributes() method—columns.Bound(o => o.Freight).FooterHtmlAttributes(new { style = "text-align: right" });.

    This demo shows how to change the alignment of the default column text and value in the ASP.NET Core Data Grid.

    For more information about the approaches for taking the best out of the component, refer to the official Telerik UI for ASP.NET Core Data Grid product documentation.

    Additional Apps

    This Grid example is part of unique collection of hundreds of ASP.NET Core demos, with which you can see all Telerik ASP.NET Core components and their features in action. View the source code of the demos from the library or directly adapt, and edit them and their theme appearance in Telerik REPL for ASP.NET Core or ThemeBuilder.

Support & Learning Resources

Additional Resources