Set the CurrencyNegativePattern for whole grid

Hi team,

the grid by default will render negative number as (90) instead of -90,

in order to render the minus symbol, I can set the column template with 

                            CultureInfo currentCulture = Thread.CurrentThread.CurrentCulture;
                            CultureInfo newCulture = new CultureInfo("en-US");
                            newCulture.NumberFormat.CurrencyNegativePattern = 1;
                            Thread.CurrentThread.CurrentCulture = newCulture;

The thing is it is too trouble some to do this with all the columns, is there anyway to set the negative number properly once for all?

1 Reply

VN Vignesh Natarajan Syncfusion Team February 12, 2020 10:39 AM UTC

Hi Feifan, 

Thanks for contacting Syncfusion forums.  

Query: “The thing is it is too trouble some to do this with all the columns, is there anyway to set the negative number properly once for all? 

Yes. You can achieve your requirement by defining the NegativeCurrencyFormat of CultureInfo in the startup.cs file. Refer the below code example.  

[startup.cs] 

public void ConfigureServices(IServiceCollection services) 
       { 
           services.AddRazorPages(); 
           services.AddServerSideBlazor(); 
           services.AddSingleton<WeatherForecastService>(); 
           services.Configure<RequestLocalizationOptions>(options => 
           { 
               options.DefaultRequestCulture = new RequestCulture("en-US"); 
               options.DefaultRequestCulture.Culture.NumberFormat.CurrencyNegativePattern = 1;                 
           }); 
           services.AddSyncfusionBlazor(); 
       } 
public void Configure(IApplicationBuilder appIWebHostEnvironment env)       {. . . . . . . ..               app.UseRequestLocalization();       //    #endregion. . . . . . ..        }

Note: Kindly ignore the solution provided in the Forum 150622, if you want to apply the negative format for all the grids and numbers.   

Kindly get back to us if you have further queries.  

Regards, 
Vignesh Natarajan. 
 


Loader.
Up arrow icon