Currency Format

Hi,

I am attempting to use the Currency option within the SfNumericTextBox, even if I specify a currency i.e. USD or GBP it does not change from the current locale, there is no documentation that I can see on this option. I either get no currency format or the wrong currency Format.

                        <SfNumericTextBox @bind-Value="CurrencyValue" 
                                          TValue="decimal"
                                          ShowSpinButton="true"
                                          Format="c2"
                                          Currency="GBP"
                                          Placeholder="Currency"
                                          FloatLabelType="FloatLabelType.Always"></SfNumericTextBox>

This is the screengrab that shows this should work, however, I still do not know where the documentation would be for this.

3 Replies 1 reply marked as answer

SP Sureshkumar P Syncfusion Team June 18, 2020 09:59 AM UTC

Hi Max,  
   
Greetings from Syncfusion support.  
   
We would like to inform you that from the latest release version (from 18.1.42), we have changed the formatting based on the CLDR-data to C# cultureInfo based formatting. So, we need to set the currency code in the startup.cs file as mentioned below code example to render the Numeric TextBox component with corresponding culture.  
   
[Startup.cs]  
public void ConfigureServices(IServiceCollection services)  
        {  
            services.AddSyncfusionBlazor();  
            services.AddLocalization(options => options.ResourcesPath = "Resources");  
            services.Configure<RequestLocalizationOptions>(options =>  
            {  
                //    // define the list of cultures your app will support  
                var supportedCultures = new List<CultureInfo>()  
            {  
                new CultureInfo("en-US"),  
                new CultureInfo("de")  
            };  
  
                // set the default culture  
                options.DefaultRequestCulture = new RequestCulture("de");  
                options.DefaultRequestCulture.Culture.NumberFormat.CurrencySymbol = supportedCultures[1].NumberFormat.CurrencySymbol;  
                options.SupportedCultures = supportedCultures;  
                options.SupportedUICultures = supportedCultures;  
                options.RequestCultureProviders = new List<IRequestCultureProvider>() {  
                 new QueryStringRequestCultureProvider()  
                };  
            });  
            services.AddRazorPages();  
            services.AddServerSideBlazor();  
            services.AddSingleton(typeof(ISyncfusionStringLocalizer), typeof(SampleLocalizer));  
            services.AddSingleton<WeatherForecastService>();  
        }  
[index.razor]  
@using Syncfusion.Blazor.Inputs  
  
<SfNumericTextBox TValue="int?" Format="c2"></SfNumericTextBox>  
  
   
Please find the sample from the below link.  
   
Please find the documentation from the below link.  
   
Please find the NumberFormat properties from the below .NET Core documentation link.  
   
Regards,  
Sureshkumar P 
 


Marked as answer

MA Max June 18, 2020 12:21 PM UTC

Hi,

This doesn't appear to answer what I was looking for, essentially I have a place where a user will specify the currency and then that will be used, localization is not helpful as that does not achieve this, all the below shows it setting each localization, which if I'm not mistaken Blazor and C# have pre-built in.

I was hoping to use the currency field in my example to then set the correct currency

                        <SfNumericTextBox @bind-Value="CurrencyValue" 
                                          TValue="decimal"
                                          ShowSpinButton="true"
                                          Format="c2"
                                          Currency="GBP"
                                          Placeholder="Currency"
                                          FloatLabelType="FloatLabelType.Always"></SfNumericTextBox>

Regards,
Max.


SP Sureshkumar P Syncfusion Team June 19, 2020 01:04 PM UTC

Hi Max, 
 
Thanks for your update. 
 
We would like to say this, we have provided culture support from server side. So, we could not give the currency code in the component rendering tag. You need to give the currency code as like previous update (from the C# code).  
 
Regards, 
Sureshkumar P 


Loader.
Up arrow icon