Html.Grid right align data in column

SO User picture SO User · Aug 19, 2010 · Viewed 7.4k times · Source

In an Html.Grid, how can we ensure that data in the column (e.g. currency amounts) gets right aligned?

Thanks.

Answer

David picture David · Aug 19, 2010

You mean in the MvcContrib Grid?

You could use something like:

column.For(x => x.Amount).Attributes(style => "text-align:right");

or more tidily you could set a class:

column.For(x => x.Amount).Attributes(@class => "right-align");

and set an appropriate style rule on that class.