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

3 posts, 1 answers
  1. Travis
    Travis avatar
    3 posts
    Member since:
    Sep 2013

    Posted 13 Sep 2013 Link to this post

    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. Georgi Krustev
    Admin
    Georgi Krustev avatar
    3706 posts

    Posted 17 Sep 2013 Link to this post

    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!
  3. Kendo UI is VS 2017 Ready
  4. Answer
    Travis
    Travis avatar
    3 posts
    Member since:
    Sep 2013

    Posted 17 Sep 2013 Link to this post

    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.
Back to Top