In an Html.Grid, how can we ensure that data in the column (e.g. currency amounts) gets right aligned?
Thanks.
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 .
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With