Wrong currency unit in Kendo

2019-08-09 10:41发布

In my website I use the Kendo-grid. In that grid, there is a column "Amount" with these values: Amount-column in Kendo Grid

You see that there are dollar-signs before the amounts, but I want euro-signs.

The globalization-culture settings are correct, because when I show an amount outside the grid, it shows me the amount with a euro-sign.

I'm developing this website with ASP.NET MVC5. In my model I have this property:

[DisplayFormat(DataFormatString = "{0:c}")]
public decimal Amount { get; set; }

You see that I format my string to currency (and my globalization-culture settings are correct)

Could anyone help me please?

Note: It is not an option to convert the amount to a string, because I have to sort that column. And with strings, it is unable to sort numbers like normal decimals. Strings will be sorted like "1, 11, 2, 20, 3" instead of "1, 2, 3, ..."

1条回答
太酷不给撩
2楼-- · 2019-08-09 11:21

When you say you have included the correct Globalization settings how are you doing this e.g. via web.config like:

  <system.web>
    <globalization culture="en-GB" uiCulture="en-GB" />
  </system.web>

or via C# e.g.

Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo("en-GB");
Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo("en-GB"); 

Assuming these are the ways you are setting the culture for your site have you also include the relevant Kendo Culture script onto your site:

eg.

<script src="@Url.Content("~/Scripts/kendo/2015.1.511/cultures/kendo.culture.en-GB.min.js")"></script>

Note: change version and culture settings to your version and required culture e.g. fr-FR, en-US etc and then setting the included culture like so:

<script type="text/javascript">
      kendo.culture("en-GB");
</script>

Note: Change the en-GB for whatever culture you have specified in the culture script.

This will then set all the kendo controls use the same culture and you don't have to specify it per control.

see this link for more details: Kendo Globalization Help

Hopefully this will help you out. Any issues let me know and hopefully we can find out why the en-US setting is being used (it is the default language for the kendo controls)

查看更多
登录 后发表回答