KoolReport's Forum

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

Koolphp Table prevent auto rounding off #1902

Closed ankit raj opened this topic on on Feb 12, 2021 - 2 comments

ankit raj commented on Feb 12, 2021

Hi , I am using koolphp table and it is rounding off one decimal place automatically to integer. How should i turn it off? I am using minimum configuration:

        \koolreport\widgets\koolphp\Table::create(array(
            "themeBase"=>"bs4",
            "cssClass"=>array(
                "table"=>"table table-striped table-bordered y-sum-table"
            ),
            "dataSource"=>$data['first_table'],
//            "columnDefs" => array(
//                array("type"=> "html-num", "targets" => [1])
//            ),
            "showFooter"=>false,
            "options"=>array(
                "order" => [],
                "bInfo" => false,
                "dom" => 'Bfrtip',
                "buttons" => [
                    array(
                        'extend'=>'excelHtml5',
                        'text'=>'<i class="fa fa-file-excel-o"></i>',
                        'titleAttr'=>'Excel'
                    )
                ],

            )
        ));
David Winterburn commented on Feb 15, 2021

Hi,

The Table widget uses a column's meta data to decide how to display its values. By default, if a number column has no "decimals" meta the table considers its "decimals" = 0 which explains the rounding off. To avoid it please either set a column's "decimals" meta = 1, 2, etc or set its type = "string". We will consider adding a universal meta for all columns for users' convenience in the future. Thanks!

ankit raj commented on Feb 18, 2021

Thanks. For now i just did formatvalue=> and then directly returned $value. But Yes for future it would be a good idea to check if its a decimal before truncating it.

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
help needed

None