This project is read-only.

Currency formatting

Jul 3, 2013 at 7:19 PM
Hi, how can I give currency format to a column?

I am adding columns like this:

columns.Add(i => i.ADecimalField).Titled("whatever");

is there a way to give it a currency format?
Jul 4, 2013 at 3:57 AM
Hi, yes.

You can use Format method to setup format specifier:
columns.Add(i => i.ADecimalField).Titled("whatever").Format("{0:F}");
More about specifiers:

Also you can use RenderValueAs to specify custom layout for rendering cell value
Jul 4, 2013 at 5:01 PM

Thank you
Jun 2, 2014 at 4:17 PM
I was not able to get the above solution working. My model returns a double. Here is the code below.

columns.Add(i => i.Cost) //where cost is a double (1.99) etc.
    .Format("{0:F}")  // Does not work for some reason
    .RenderValueAs(i => "$" + i.Cost  ); //had to manually format
Jun 2, 2014 at 5:27 PM
Try to use:
See more about format specifiers: