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

using jQuery.telerik.cultureInfo Clientside to format numbers?

2 Answers 132 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Jesse
Top achievements
Rank 1
Jesse asked on 02 Nov 2010, 06:47 PM
is it possible to use jQuery.telerik.cultureInfo Clientside to format numbers?

my example;
in controller I set the CurrentThread.CurrentCulture to 'fr-FR'
then set Globalization(true) on the ScriptRegistrar

then I add a numerictextbox with a client side change event which updates a div to display the value that was entered;

@Html.Telerik(
    ).NumericTextBox(
    ).Name("Hours"
    ).ClientEvents(events => 
        events.OnChange("onChangeHours")
    )

and the javascript
function onChangeHours(e) {
    $('total-hours-div').text(e.newValue);
}

really I will have multiple numerictextboxes and the div will be displaying the sum of all values

everything works perfectly - values in the numerictextbox display in fr-FR format 7,77
but the clientside object e.newValue will contain the en-US value 7.77 - this is good because I can easily add the value to other numbers, etc...

but when I set the display of the div I want to apply the same formatting that the numbertextbox is using

Does telerik expose any clientside helper methods that I can use in conjunction with the jQuery.telerik.cultureInfo object to get my formatting displayed in the users culture?

Thanks in advance

- Jesse

2 Answers, 1 is accepted

Sort by
0
Accepted
Hristo Germanov
Telerik team
answered on 03 Nov 2010, 08:49 AM
Hello Jesse,

You can use format client method to format parsedValue(in your case e.newValue) with current culture. The following code snippet shows how to do this:
function onChangeHours(e) {
    var textBox = $('#NumericTextBox').data('tTextBox');
    $('total-hours-div').text(textBox.format(e.newValue));
}
 
Regards,
Hristo Germanov
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Jesse
Top achievements
Rank 1
answered on 03 Nov 2010, 07:22 PM
Thanks Hristo,

it worked perfectly

Tags
General Discussions
Asked by
Jesse
Top achievements
Rank 1
Answers by
Hristo Germanov
Telerik team
Jesse
Top achievements
Rank 1
Share this question
or