Disable rounding in CFGRID

Posted on 2011-04-28
Medium Priority
Last Modified: 2012-06-22
I am using a cfgrid to edit pricing that goes down the three decimal places, such as 0.315 but cfgrid keeps rounding them up to the nearest 2nd decimal, such as 0.32 for the number above. Is there a way to disable the round in cfgrid?
Question by:blitzone
  • 4
  • 3

Author Comment

ID: 35488935
I have also tried numberformat="9.999" on the column.
LVL 52

Expert Comment

ID: 35488977
What version of CF and where is the rounding occurring (view, on edit, on submit)?

Author Comment

ID: 35489004
CF9 and after I do an edit.
NFR key for Veeam Backup for Microsoft Office 365

Veeam is happy to provide a free NFR license (for 1 year, up to 10 users). This license allows for the non‑production use of Veeam Backup for Microsoft Office 365 in your home lab without any feature limitations.

LVL 52

Accepted Solution

_agx_ earned 2000 total points
ID: 35493161
I don't think it can be changed via the cfgrid's properties. But you can grab the grid's Ext editor and change it's settings so it uses 3 decimal places.

<!--- sample data for testing ---->
<cfset myQuery = queryNew("")>
<cfset queryAddColumn(myQuery, "MyValue", "Double", listToArray("0.315,0.258,0.75"))>

<script type="text/javascript">
	function initGrid() {
		mygrid = ColdFusion.Grid.getGridObject('MyGrid');
		cm = mygrid.getColumnModel();
		// get cell editor for the number column
		// column index is 0 based ...
		e = cm.getColumnAt(0).getEditor();
		// force 3 decimal places
		e.decimalPrecision = 3;
<cfform format="html"> 
    <cfgrid name="MyGrid" query="myQuery" format="html" selectmode="edit">  
		 <cfgridcolumn name="MyValue" header="My Number##" type="numeric"> 

<cfset ajaxOnLoad("initGrid")>

Open in new window


Author Comment

ID: 35495556
That worked when I typed it in and then click on another cell, it didn't round it up but when if I hit the update button it still rounds it up. My apologies if I didn't give the correct problem last night, long day.

Author Comment

ID: 35495604
My fault, I had the update script as

cfsqltype="cf_sql_decimal" scale="2"

when it should have been:

cfsqltype="cf_sql_decimal" scale="3"

Works perfectly now. Thank you very much.
LVL 52

Expert Comment

ID: 35495631
Welcome :)

Featured Post

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

By, Vadim Tkachenko. In this article we’ll look at ClickHouse on its one year anniversary.
In this article, we’ll look at how to deploy ProxySQL.
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
Suggested Courses
Course of the Month16 days, 15 hours left to enroll

864 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question