NumericTextBox custom formatter

5 posts, 0 answers
  1. Achilleas
    Achilleas avatar
    3 posts
    Member since:
    Aug 2014

    Posted 17 Oct 2014 Link to this post

    Hello,

    I need to format the contents of a NumericTextBox in javascript based on the DecimalSymbol and NumberSeparator properties that I get from a CRM Dynamics UserInfo object. That is, I would like to generate a format string that looks more or less like this:
    "###.#,##" in the case the DecimalSymbol is ',' and the NumberSeparator is '.'
    "###,#.##" in the case the DecimalSymbol is '.' and the NumberSeparator is ','

    I need to be able to do this possibly without using the kendo.culture() setter, because there is no specific culture coming from CRM, it is all 'hand-made'.

    I tried doing this but without setting the culture, the decimal separator is ignored.

    $("#amounttxt").kendoNumericTextBox({
            format: "###.#,##",
            spinners: false
        });

    Any ideas?

    Thanks in advance!
  2. Georgi Krustev
    Admin
    Georgi Krustev avatar
    3706 posts

    Posted 21 Oct 2014 Link to this post

    Hello Achilleas,

    Kendo UI NumericTextBox widget supports different internationalization (culture scripts) that can be defined using the culture option. Here is a demo that demonstrates how to accomplish this.

    Regards,
    Georgi Krustev
    Telerik
     
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
     
  3. Kendo UI is VS 2017 Ready
  4. Achilleas
    Achilleas avatar
    3 posts
    Member since:
    Aug 2014

    Posted 21 Oct 2014 in reply to Georgi Krustev Link to this post

    Thanks Georgi, this is a possible workaround but it does not really answer my question. As I said, I need to be able to do this without setting the culture to a standard. I see here that you can create maybe a custom culture object on the fly and feed it to your javascript page, however, in my case I would like to manipulate properties like 

    //string that separates the number groups (1,000,000 %)
    ",": ",",
    //string that separates a number from the fractional point
    ".": ".",
    which are not accessible from the object. Or am I wrong?

    The way I thought of doing it would be something like:
    kendo.culture().numberFormat.decimals = "2";
    but in my case, instead of the "decimals" property I need to access the "," and the "." properties that I mention above. Can this be done easily? For example:
    kendo.culture().numberFormat.decimalSeparator = ","; (or sth like that...)


    Cheers,
    Achilles





  5. Georgi Krustev
    Admin
    Georgi Krustev avatar
    3706 posts

    Posted 21 Oct 2014 Link to this post

    Hello Achilles,

    The custom numeric/date format specifies are culture related and you will need to manipulate the culture settings manually. The approach that you've mentioned is the only feasible one, I must admit, if the requirement is to build the culture information dynamically. Here is an example that demonstrates one possible way to accomplish your goal. You can either build custom culture like in the demo or to modify the current used one that kendo.culture() method returns.

    Regards,
    Georgi Krustev
    Telerik
     
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
     
  6. Achilleas
    Achilleas avatar
    3 posts
    Member since:
    Aug 2014

    Posted 22 Oct 2014 in reply to Georgi Krustev Link to this post

    Now, this answer is awesome and it worked like a charm! Thanks a lot Georgi.

    Cheers,
    Achilles
Back to Top
Kendo UI is VS 2017 Ready