1

I am using Kendo numericTextBox to display the currency. I have a requirement to format the value based on the currency selected. I am able to format the currency correctly for "en-US" and "de-DE" but I'm having trouble to format the currency correctly for culture have different group size.

All the example and sample in Kendo blog are on "en-US" and "de-DE" which have similar group size.

For "en-US" currency groupSize property is [3] what means that each group will be separated after 3 digits e.g. 1,000,000. But for some other culture which have different grouping, e.g. "en-IN" which have the 'groupSize' equals [3,2,0], kendo still group the number in group of 3 only: 1,000,000, while we expect the grouping to be 3 digits then separator then group of 2 digits etc.: 10,00,000.

Can anyone help me out on this?

Here is my code sample: http://dojo.telerik.com/@jayesh-jayakumar/AtojA/8

Jarosław Kończak
  • 3,387
  • 2
  • 19
  • 36

1 Answers1

0

So the problem is you are using old KendoUI version without this feature implemented. Here is a snippet with newest kendo version and it looks that it behaves diffrent for en-IN: http://dojo.telerik.com/aqEwun

However I'm not sure if this is exacly how it works in this culture cause it creates only 2 groups of digits as you can see on my example (from decimal separator it is group of 2, group of 3 and rest of digits).

EDIT:

So as you mentioned you would like to have different behavior that this in example (starting from decimal point one group of 3 digits and then groups of 2). It seems it's a bug and maybe telerik will fix it one day. Until then, you can change groupSize value in culture object from [3, 2, 0] to [3, 2] to achieve what you want.

To fix it globally in all linked cultures you can use following code:

  for(var i in kendo.cultures){
    var culture = kendo.cultures[i];
    if(JSON.stringify(culture.numberFormat.groupSize) === '[3,2,0]'){
      culture.numberFormat.groupSize = [3, 2];
    }
    if(JSON.stringify(culture.numberFormat.currency.groupSize) === '[3,2,0]'){
      culture.numberFormat.currency.groupSize = [3, 2];
    }
    if(JSON.stringify(culture.numberFormat.percent.groupSize) === '[3,2,0]'){
      culture.numberFormat.percent.groupSize = [3, 2];
    }
  }

PS. You may consider use better array comparing function than JSON.stringify().

Updated snippet: http://dojo.telerik.com/aqEwun/3

Jarosław Kończak
  • 3,387
  • 2
  • 19
  • 36
  • Oh. Okay I will update the version of KendoUI and check how it function. But as you mentioned, the grouping is not correct. Even though first two grouping are rightly marked, the rest of the digit are grouped together. This is not as expected. Is it any way possible of creating a custom currency format based on the group size at client side? – Jayesh Jayakumar Feb 21 '17 at 11:40
  • I tried with custom formats but without success. However I updated my answer with solution involving the changes of culture definition. – Jarosław Kończak Feb 21 '17 at 12:28
  • Thanks a lot @Jaroslaw . This work around will help me generate a more generic solution to handle different culture with same group size issue. Thank you for the insight. Like you mentioned, I hope telerik will come up with a solution to the issue soon. One more .. if you think that my question is a valid one, then pls upvote . :) – Jayesh Jayakumar Feb 21 '17 at 14:17