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

Can you override parts of the culture (not the whole culture) for individual NumericTextBox instances?

2 Answers 329 Views
NumericTextBox
This is a migrated thread and some comments may be shown as answers.
Travis
Top achievements
Rank 1
Travis asked on 13 Sep 2013, 08:34 PM
We have an application that allows for working in multiple currencies and supports localization. For example, I may speak US English but might be working (on the same page) with Yen, Euros, and US Dollars. As I work with/edit these currencies, I should see the decimal and thousands separator in US English but the currency symbol (and possibly positioning, decimal places, etc.) will change based on the currency.

We want to use the NumericTextBox for currency input and formatting, but it appears the currency format only comes from the ambient page-level culture - there isn't a straightforward way to say "use US English with these modifications just for this Yen currency entry textbox, and use US English with these different modifications just for this Euro entry textbox."

I am currently pursuing an option where I somehow replace the _format function on the NumericTextBox widget so it gets the culture but then also allows for field-level overrides before returning the complete number format.

Am I overlooking something obvious? Is there a better way to accomplish this?

2 Answers, 1 is accepted

Sort by
0
Georgi Krustev
Telerik team
answered on 17 Sep 2013, 09:16 AM
Hello Travis,

 
The NumericTextBox widget, as other Kendo input widgets, depends on the current culture (default is "en-US") or the culture defined by culture option. If you need to change the culture used by a specific widget then use culture option. You can also create a custom culture settings using this format.
This online demo, shows how to change cultures on the client.


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
Accepted
Travis
Top achievements
Rank 1
answered on 17 Sep 2013, 02:42 PM
I saw those demos but unfortunately my use case is slightly more granular.
  • Page overall culture set to en-US.
  • First text box uses Yen for currency - update currency symbol, decimals, positive/negative formats, but everything else is en-US.
  • Second text box uses US dollars for currency - no updates.
  • Third text box uses Euros for currency - update currency symbol, decimals, positive/negative formats, but everything else is en-US.
It'd be preferable to not load three different cultures on the page just for that. Plus they're all technically "en-US" so there'd be some interesting customization where we have, like, "en-US-Yen" and "en-US-Euro" - combinatoric sets of cultures on a culture/currency basis. Or a programmatic handler to generate all of those.

Most likely we'll go with a simpler option: override the NumericTextBox _format method so I can get the current culture for the box... and then look at some additional data-* attributes on the box to spot-weld the overrides into place.

It would be nice to have an event for the NumericTextBox format so I can do this in a more supported way.
Tags
NumericTextBox
Asked by
Travis
Top achievements
Rank 1
Answers by
Georgi Krustev
Telerik team
Travis
Top achievements
Rank 1
Share this question
or