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

$.telerik.formatString documentation

2 Answers 165 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.
Hiram
Top achievements
Rank 1
Hiram asked on 04 Apr 2012, 05:22 PM

I'm Using ASP.Net MVC

1- How do I find $.telerik.formatString documentation. I see samples when using grids with AJAX bindings, but cannot find the actual documentation?
2- I need to format data depending on client browser culture while respecting the value’s attributes. For instance: I want to display currency fields with the proper numeric representation of the client culture, while keeping the currency code/symbol of the value (if the currency is USD it should show as $ no matter how the client view numbers $1,234.56 or $1234,56, since changing the currency code without currency conversion is not acceptable).

I have the following logic working for server side formatting, but I need similar logic for client side:

 

public static string GetCurrencyFormated(decimal? val)

{

  if (val.HasValue)

    return string.Format("$ {0}", val.Value.ToString("f"));

  return string.Empty;

}

Thank you

2 Answers, 1 is accepted

Sort by
0
Petur Subev
Telerik team
answered on 09 Apr 2012, 04:49 PM
Hello Hiram,

Currently we don't have any documentation for the formatString utility method method but it will be added in the future.
Basically the method covers most of the functionality provided by the C# string.Format method - all the stuff with placeholders
e.g.
$.telerik.formatString("test {0:C3}",2323.3434) -> "test $2,323.343"

Regarding to the globalization question - you should enable globalization (in the ScriptRegistrar config).


All the best,
Petur Subev
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the Telerik Extensions for ASP.MET MVC, subscribe to their blog feed now.
0
Marco Teodoro
Top achievements
Rank 1
answered on 22 Jun 2012, 12:38 PM
Just forget, ist working. it was just a cache error.

i have set the globalization attribute to true like this:

@(Html.Telerik().ScriptRegistrar().DefaultGroup(group =>
       group.Add("~/Scripts/slimScroll.min.js")
       .Add("~/Scripts/jquery-ui-1.8.11.min.js")
       .Add("~/Scripts/jstween-1.1.min.js")
       .Add("~/Scripts/jquery.ballon.js")
       .Add("~/Scripts/Common.js")
       .Add("~/Scripts/jquery.ae.image.resize.min.js")
       .Add("~/Scripts/json2.js")
       .Add("~/Scripts/jquery.mousewheel.js")
       .Add("~/Scripts/antiscroll.js")
       .Add("~/Scripts/f5tooltip.js")
       .Add("~/Scripts/f5login.js")
       .Add("~/Scripts/jquery-ui-1.7.2.custom.min.js")
       .Add("~/Scripts/jquery.flip.min.js")
       .Combined(false).Compress(true)).Globalization(true))

but when i do $.telerik.formatString("{0:C}",value) the returned value  always have $ as currency symbol

Is the string format function culture aware or not?

and of course i'm setting the cultureui and culture to pt-PT so i think i should see a € symbol, for the time being :)

Tags
General Discussions
Asked by
Hiram
Top achievements
Rank 1
Answers by
Petur Subev
Telerik team
Marco Teodoro
Top achievements
Rank 1
Share this question
or