KoolReport's Forum

Official Support Area, Q&As, Discussions, Suggestions and Bug reports.
Forum's Guidelines

Unable to set decimal to 2 places , not working in datagrid #855

Open iRiyada opened this topic on on May 7, 2019 - 3 comments

iRiyada commented on May 7, 2019

created a new column in datastore based on existing columns

 $new_delay_count = $this->dataStore("delay_count")->process(new CalculatedColumn(array(
            "ratio"=>array(
                "exp"=>"{delay_count}*100/{all_count}",
                "type"=>"number",
                "decimals"=>2
                
            ))));;?>

Setting properties to that column

"ratio"=>array(

            "label" => "النسبة",                    
            "cssStyle"=> "width:100px",
            
            "type"=>"number",
            "decimals"=>2,                                                                                                   //eg $value=20.1234556789
            "formatValue"=>function($value)
            {   
                $color = $value>20?"#e83e8c":"#000000";
                return "<span style='color:$color'>".$value."</span>";
            }    ,
        
            

        ),

I have tried "type"=>"number", "decimals"=>2, in column property, during column creation , also both together as shown here. tried $value/10000000=it is giving exponent values.

iRiyada commented on May 7, 2019

It is enough to use table instead of datagrid. but still decimal places causing error

David Winterburn commented on May 7, 2019

Hi,

If you use the "formatValue" property, the decimals property is no longer effective. Please use the number_format function in your "formatValue" function's return value to show decimals. Let us know if we understand your requirement correctly. Thanks!

iRiyada commented on May 13, 2019

oh.ok. I resolved it with php round() function. may be i should try this. Thank you for the support.

Build Your Excellent Data Report

Let KoolReport help you to make great reports. It's free & open-source released under MIT license.

Download KoolReport View demo
None yet

None