Start Building Professional
Web Apps Today


 
Categories Question details Back To List
Question  posted by Adrianne on Apr 01, 2008 02:29
open dhtmlx forum
when setNumber is set, cells actually use rounded values in math formulas instead of just displaying rounded values

Hello there,

I'm using the setNumber mask like this "0,000" (no decimals). I have math formulas in each cell of my XML.

I noticed that when I use the setNumber mask, the cells are calculated using the rounded value. For example.

Say the result of math formula in cell [[1,1]] is 559.40. When setNumber is set, the rest of the cells which use [[1,1]] in their formulas use the rounded value of 559 and not 559.40 which can lead to inaccurate results compared to Excel. Hope I'm explaining this properly. I don't want to give up the setFormat mask because I want the thousands separator but is there any way to solve this problem?

Thank you
Answer posted by Support on Apr 01, 2008 08:20
Problem confirmed, the math use default getValue to retrieve value of cell, which will be a formated value not the original one - this behavior can't be easily changed without side effects.

You can
    a) show the necessary count of decimal points in your formatted output
or
    b) modify dhtmlxgridcell.js in next way

function eXcell_edn(cell){
    ...
    this.getValue = function(){
       return this._val;      // <= this line need to be added
       ...
eXcell_edn.prototype.setValue = function(val){
       this.cell._val=val;   // <= this line need to be added