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

GridNumericColumn with Negative Value

12 Answers 1190 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Brian Chavez
Top achievements
Rank 2
Brian Chavez asked on 08 Feb 2009, 11:04 PM
Hi,

How do I make the GridNumericColumn display negative numbers in the folowing "$ -40.00" format.  RadNumericTextbox has a NegativePattern, but I'm not able to set a negative pattern in GridNumericColumn.  GridNumericColumn seems to display negative values in "($40.00)" format.

This is annoying.

Thanks,
Brian

12 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 09 Feb 2009, 04:38 AM
Hi Brian,

Try setting the DataFormatString instead of setting the NumericType property. Try the following ASPX for GridNumericColumn. Hope this helps.

<telerik:GridNumericColumn DataField="UnitPrice" DataType="System.Decimal" DataFormatString="${0}" HeaderText="NumericColumn"
</telerik:GridNumericColumn> 

Thanks,
Shinu.
0
rick
Top achievements
Rank 1
answered on 01 May 2009, 07:36 PM
I'm using the GridCalculatedColumn and would like to show the NumericType as currency (23.00) rather than -23.00. How is this achieved in the GridCalculatedColumn?

 

0
Sebastian
Telerik team
answered on 04 May 2009, 12:15 PM
Hi rick,

I replied to your question in the support ticket you opened with regards to this subject. I am pasting the response in this forum thread as well:

Can you please try setting DataType = "System.Decimal" and appropriate DataFormatString for the GridCalculatedColumn you mentioned to format the numeric value in it in par with your preferences? Let me know whether this produces the desired result.

Best regards,
Sebastian
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Johann Herunter
Top achievements
Rank 1
answered on 09 Dec 2009, 01:12 PM
Hello,

I'm having the same problem when assigning a negative format pattern, but need to support automatic currency assignment.

The RadNumericTextBox gets the format "$-n" assigned, which works good for negative numbers for Dollar.

With using the DataFormatString "${0}" (as suggested), the number displays correctly, but changing the currency (using a new CultureInfo object on the Thread.CurrentThread.CurrentCulture) to Euro, the Dollar symbol is not replaced with the Euro symbol.

We need to display positive and negative numbers in Dollar and Euro, which must be changed at runtime.

The only way seems to assign the CurrencyNegativePattern on the current Thread, which is a problem in the environment the grid is running in.

Could you please give a suggestion, how it is possible to assign a currency-indepentend format for both positive and negative values?

Regards,
Johann
0
Sebastian
Telerik team
answered on 14 Dec 2009, 08:35 AM
Hello Johann,

You need to include the relevant currency symbol explicitly either separately or as part of the value which is processed by the column's DataFormatString. See how this is done programmatically for the Currency column on the following online demo of RadGrid for ASP.NET AJAX:

http://demos.telerik.com/aspnet-ajax/grid/examples/client/columnformatting/defaultcs.aspx

and try it in your case to see whether this produces the desired result.

Best regards,
Sebastian
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Asutosh
Top achievements
Rank 1
answered on 22 Jul 2014, 12:57 PM
we have a requirment where we need commas in usd currency format along with $ and minus sign but when we try to put commas with 0:c it shows commas but it encodes negative values in braces and we want minus sign and instead of showing negative values in braces. any solution ?
0
Eyup
Telerik team
answered on 25 Jul 2014, 07:13 AM
Hello Asutosh,

You can use a custom formatting to achieve the requested appearance:
double value = -2.54;
string formattedValue = string.Format("{0:$#.##;$-#.##}", value);

Hope this helps. Please give it a try and let me know if it works for you.

Regards,
Eyup
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
0
Asutosh
Top achievements
Rank 1
answered on 25 Jul 2014, 07:25 AM
we want to bind this formate in radgrid and radhtml chart 
how to do that in that?
0
Eyup
Telerik team
answered on 25 Jul 2014, 08:49 AM
Hello Asutosh,

You can use the corresponding properties of the controls to apply the desired formatting:
<telerik:GridNumericColumn ... DataFormatString="{0:$#.##;$-#.##}">

That should do the trick.

Regards,
Eyup
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
0
Asutosh
Top achievements
Rank 1
answered on 25 Jul 2014, 09:42 AM
thanks for reply
and what about radhtml chart?
0
Danail Vasilev
Telerik team
answered on 30 Jul 2014, 10:23 AM
Hello Asutosh,

If you want to format values in RadHtmlChart's labels or tooltips you can also use the DataFormatString property. If you want, however, to format values in templates you must use kendo.format() method. More information on the matter is available in the following set of help articles:

 - Formatting Dates
 - Formatting Numbers
 - Overview

Regards,
Danail Vasilev
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
0
Sasp
Top achievements
Rank 1
answered on 09 Aug 2019, 11:56 AM

I want to show value in grid, if negative then to show within parenthesis. Means, if my value is -1.25 then it should show like (1.25) and this is achieved by below code.

TryCast(col, GridBoundColumn).DataFormatString = "{0:#.##;(#.##)}"

 

But when the negative value is:  -3.00 then it is showing (3) , it is missing the decimal precision. Please provide a correct formatString to show .00 precision when negative. For your information, it is showing positive values correctly with .00 precision.

Thanks and waiting for reply.

Tags
Grid
Asked by
Brian Chavez
Top achievements
Rank 2
Answers by
Shinu
Top achievements
Rank 2
rick
Top achievements
Rank 1
Sebastian
Telerik team
Johann Herunter
Top achievements
Rank 1
Asutosh
Top achievements
Rank 1
Eyup
Telerik team
Danail Vasilev
Telerik team
Sasp
Top achievements
Rank 1
Share this question
or