Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Html.Grid right align data in column

Tags:

mvccontrib

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

Thanks.

like image 366
SO User Avatar asked Aug 19 '10 04:08

SO User


People also ask

How do you align items inside a grid cell?

To align the item horizontally within the grid, we use the justify-content property and set it to center . With justify-content we can align the columns start , end , stretch or center .

How do you make a column on the right side in HTML?

To position them side by side, we can set to both “div” elements the “float: left” property, specifying the element float to left. Now we need to push the right column to the right side of the page. We can achieve the result by using the “margin” CSS property in a non-standard way.


1 Answers

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.

like image 89
David Avatar answered Sep 22 '22 03:09

David