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

NumericTextBox custom formatter

4 Answers 180 Views
NumericTextBox
This is a migrated thread and some comments may be shown as answers.
Achilleas
Top achievements
Rank 2
Achilleas asked on 17 Oct 2014, 01:50 PM
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!

4 Answers, 1 is accepted

Sort by
0
Georgi Krustev
Telerik team
answered on 21 Oct 2014, 08:53 AM
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!
 
0
Achilleas
Top achievements
Rank 2
answered on 21 Oct 2014, 09:23 AM
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





0
Georgi Krustev
Telerik team
answered on 21 Oct 2014, 12:37 PM
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!
 
0
Achilleas
Top achievements
Rank 2
answered on 22 Oct 2014, 11:04 AM
Now, this answer is awesome and it worked like a charm! Thanks a lot Georgi.

Cheers,
Achilles
Tags
NumericTextBox
Asked by
Achilleas
Top achievements
Rank 2
Answers by
Georgi Krustev
Telerik team
Achilleas
Top achievements
Rank 2
Share this question
or