Search code examples
mvccontrib

Html.Grid right align data in column


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

Thanks.


Solution

  • 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.