Sage SalesLogix
  • Contact Us
  • Sage North America
800-643-6400
Welcome Twitter Facebook LinkedIn
Community Home Blogs Share Ideas Search Request Access Resources
Reply
Tuned Listener
yshld
Posts: 63
Registered: 11-29-2011

Customize Datagrid Column Format

Hi,

 

I want to customize a datagrid column such that if the value if positive number, it should as 333,333, if it is negative, then show as (333,333).

 

What is the best way to do it?

 

Thanks a lot

Please use plain text.
Bronze Elite Contributor
RJSamp
Posts: 482
Registered: 03-24-2009

Re: Customize Datagrid Column Format

I actually don't know how to put () around a negative number.....remember this is Delphi based code on the LAN side of things.....

 

http://www.delphibasics.co.uk/RTL.asp?Name=Format

 

%m12.2 for money for example.....

 

The format string is placed IN the column's FormatString property.

RJ Samp
Please use plain text.
New Member
jpwelther
Posts: 9
Registered: 07-07-2011

Re: Customize Datagrid Column Format

[ Edited ]

You could make the column a Text column and format the value before it enters the grid. If you are manually setting the SQL property you might be able to pass this though the provider

 

Case WHEN {field} <0 then '(' + convert(varchar(100),abs({field})) +')'   Else {field}  END as {field}   

 

The example would be 

“Select Product, Case WHEN Price <0 then '(' + convert(varchar(100),abs(Price)) +')'   Else Price  END as Price From product”

 

Another option is to make a SQL computed Columns http://msdn.microsoft.com/en-us/library/ms191250.aspx. This will allow you to make a column on the table that is formatted like you want. The plus side of the SQL column is that it can be added to groups, and reusing it is much simpler. The downside of the computed column is that we had had problems using them on remote DBs. 

Please use plain text.