This is a migrated thread and some comments may be shown as answers.

[Solved] Grid Currency Column

3 Answers 132 Views
Grid
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Jigar
Top achievements
Rank 1
Jigar asked on 29 Sep 2010, 06:48 PM
Hi,

By default for Currency data type columns Grid shows "$", How can I change this?

Thanks,

Jigar.

3 Answers, 1 is accepted

Sort by
0
Jigar
Top achievements
Rank 1
answered on 29 Sep 2010, 07:06 PM
I did this like
OnRowDataBound event I put it like this

var amount = row.cells[11].innerHTML;
row.cells[11].innerHTML = amount.substr(1,amount.length);

I hope this helps, and Please suggest; if there is a better way to do this.

Thanks.
0
Cyndie
Top achievements
Rank 1
answered on 29 Sep 2010, 07:38 PM
I'm not using a currency datatype, but have you tried to use a fixed-point format on the column?

                                   columns.Bound(o => o.field).Format("{0:F2}");
0
Daniel Collier
Top achievements
Rank 1
answered on 12 Mar 2011, 03:52 AM
My simplest hack for this is to provide 2 copies of your currency value in the model:  one thats a decimal that you "Bound" that column to and one that is a string formatted in the currency you want, on the server side and you use a Template to show that value on the bound column.  So instead of:

columns.Bound(o => o.Cost).Format("{0:c}").Title("Cost");

You'd do something like:

columns.Bound(o => o.Cost).Template(o => {%><%=o.CostFormattedAsString%><%}).Title("Cost");

But I would love to be able to pass a CultureInfo to the column's format method instead.  And I'd love even more if I could do that with a client Template.
Tags
Grid
Asked by
Jigar
Top achievements
Rank 1
Answers by
Jigar
Top achievements
Rank 1
Cyndie
Top achievements
Rank 1
Daniel Collier
Top achievements
Rank 1
Share this question
or