Start Building Professional
Web Apps Today


 
Categories Question details Back To List
Question  posted by Daniel on Feb 28, 2008 21:12
open dhtmlx forum
Is price type cells always displayed green?

Hi,
If the column type is "price", why the font color for the price value is always green?
Even if I try to set font color (in a css style) for a cell to a different color it still print it green!

<row id="1234">
<cell class="redClass">12.50</cell>
...

</row>

this will render the dollar sign ($) red but the price value is still rendered green!

Any idea why and how we can change it?

Thanks.
Answer posted by Support on Feb 29, 2008 10:12
Actually it is part of design, column shows positive data in green, and negative ( or incorrect ) in red.

dhtmlxgridcell.js, line 1087

eXcell_price.prototype.setValue = function(val){
    ...       
        var color = "green";
        if(val<0) color = "red";
Answer posted on Feb 29, 2008 12:56

I can't see why this needs to be part of the design and not a configurable feature?

Forcing particular font color is unusual for general purpose component and styles are meant to address the look and feel issue. I hate to go an dhack the code because I could easiliy lose it in the next code release.

If something likethis is desirable and already established in the code then we should at leastbe able to override it like grid.enablePriceDefault(true/false) an dhave a call back method to handle the price look&feel.

Answer posted by Support on Mar 03, 2008 05:35
The excells used in grid are dynamically created object, it possible to create new excells ( actually this is the best way to provide custom formating|edit|validate capabilities )
The "price" excell was initially created just as a sample of excell possibility, it has no sense to add a bunch of options to each excell, while with few lines of code it possible to create a new excell type with necessary behavior.

Basically  you need not to change anything in code, because you can create your custom excell type and use it instead of standard one

function eXcell_priceA(cell){
    this.base = eXcell_price;
    this.base(cell)
}
eXcell_priceA.prototype = new eXcell_price;
eXcell_priceA.prototype.setValue = function(val){
        this.setCValue("<span>$</span><span style='padding-right:2px;'>"+val+"</span>",val);
    }

now you can use priceA , which works the same as price but without color formatting.
Answer posted on Mar 03, 2008 11:31

Perfect answer! Thank you very much!

Cheers!

Daniel,