cfgrid format="html" how to format number?


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".

Who is Participating?

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

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.

I believe "numberFormat" only applies to applets, and "mask" to flash grids

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

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

   <!--- 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 );


<!--- 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">
<!--- use AjaxOnLoad to set the currency renderer --->
<cfset ajaxOnLoad("updateCellRenderer")>

Open in new window


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
Try doing the formatting in the SQL Select statement. Which SQL are you using?
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.

jfreeman2010Author Commented:
Thank you both of your help!!
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.