We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: June 24, 2019).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Format a column with negative currency value

Thread ID:

Created:

Updated:

Platform:

Replies:

150622 Jan 14,2020 12:25 AM UTC Jan 14,2020 04:51 AM UTC Blazor 1
loading
Tags: Grid
Feifan
Asked On January 14, 2020 12:25 AM UTC

Hi Team,

Just wonder if we can format the column with negative currency value, such that the cell will display -$12.00 instead of ($12.00)

My understand is that the parenthesis is set up by the default CurrencyNegativePattern prop,  how can we override it and setting it to 1? Or we can only use Formatter to manually put a string "-" before the formatted data ?

Vignesh Natarajan [Syncfusion]
Replied On January 14, 2020 04:51 AM UTC

Hi Feifan, 
 
Greetings from Syncfusion support.  
 
Query: “ how can we override it and setting it to 1? Or we can only use Formatter to manually put a string "-" before the formatted data ? 
 
We suggest you to achieve your requirement (to display negative sign with currency symbol) using Column Template feature of Grid. Inside the template you can change the Current CultureInfo like below.  
 
<GridColumn Field=@nameof(Order.Freight) HeaderText="Freight" Format="C2" TextAlign="TextAlign.Right" Width="120"> 
            <Template> 
                @{ 
                    var ord = (context as Order).Freight; 
                    CultureInfo currentCulture = Thread.CurrentThread.CurrentCulture; 
                    CultureInfo newCulture = new CultureInfo("en-US"); 
                    newCulture.NumberFormat.CurrencyNegativePattern = 1; 
                    Thread.CurrentThread.CurrentCulture = newCulture; 
                    <span>@ord.ToString("C2")</span> 
                } 
            </Template> 
        </GridColumn> 
 
Refer our UG documentation for your reference 
 

Please get back to us if you have further queries.  
 
Regards, 
Vignesh Natarajan. 


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile
Live Chat Icon