cfgrid format="html" how to format number?

Hi

I am using coldfusion and cfgrid, need to format a currency field with $.  Both numberformat and mask are not working.  Can this be done?  the cfgrid format="html".

jfreeman2010Asked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

_agx_Commented:
I believe "numberFormat" only applies to applets, and "mask" to flash grids
http://livedocs.adobe.com/coldfusion/8/htmldocs/Tags_g-h_04.html#3988181

If you're populating the grid from a query, you could format the numbers in your db query.  For CF8 you could also use the underlying Ext functions, like Ext.util.Format.usMoney ie $xx.xx format

Credit for the adaptation goes to
http://ajaxian.com/archives/coldfusion-8-grid-magic








<cfset sampleData = QueryNew("")>
<cfset queryAddColumn(sampleData, "MoneyAmount", "Decimal", listToArray("10,15.98,90.800"))>

<html>
<head>
   <!--- create javascript function for rendering dates --->
   <script language="JavaScript" type="text/javascript">
   updateCellRenderer = function(){
      mygrid = ColdFusion.Grid.getGridObject('MyGrid');
      cm = mygrid.getColumnModel();
      // column indexes are zero based, not 1-based like in CF 
      cm.setRenderer(0, Ext.util.Format.usMoney );
      mygrid.reconfigure(mygrid.getDataSource(),cm);
   }
   </script>
</head>

<body>

<!--- Set up the Grid --->
<cfform id="MyForm" name="MyForm">
	<cfgrid name="MyGrid" format="html" pagesize="10" striperows="yes" query="sampleData">
		<cfgridcolumn name="MoneyAmount"  header="Money Amount">
	</cfgrid>
</cfform>
<!--- use AjaxOnLoad to set the currency renderer --->
<cfset ajaxOnLoad("updateCellRenderer")>
	
</body>
</html>

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
RickEpnetCommented:
Try doing the formatting in the SQL Select statement. Which SQL are you using?

http://articles.techrepublic.com.com/5100-10878_11-5803705.html
0
jfreeman2010Author Commented:
I am using T-SQL which it will work as:

'$'+ CONVERT(VARCHAR(12), SUM(TOTAL_CHARGES), 1) on the field that need to be format.

I will try  Ext.util.Format.usMoney ie $xx.xx forma also.

0
jfreeman2010Author Commented:
Thank you both of your help!!
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
ColdFusion Language

From novice to tech pro — start learning today.