Disable rounding in CFGRID

Posted on 2011-04-28
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

    Author Comment

    I have also tried numberformat="9.999" on the column.
    LVL 51

    Expert Comment

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

    Author Comment

    CF9 and after I do an edit.
    LVL 51

    Accepted Solution

    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

    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

    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 51

    Expert Comment

    Welcome :)

    Featured Post

    Gigs: Get Your Project Delivered by an Expert

    Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

    Join & Write a Comment

    Today, I was working on some optimization and spam-stopping techniques when I encountered Ben Nadel's post to reduce spam feature using Math ( While this method is not o…
    Load balancing is the method of dividing the total amount of work performed by one computer between two or more computers. Its aim is to get more work done in the same amount of time, ensuring that all the users get served faster.
    Internet Business Fax to Email Made Easy - With eFax Corporate (, you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
    Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

    746 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

    Need Help in Real-Time?

    Connect with top rated Experts

    16 Experts available now in Live!

    Get 1:1 Help Now