KoolReport's Forum

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

Decimal Option in Datatable not working after update (to koolreport 5) #1732

Closed Thomas opened this topic on on Nov 24, 2020 - 2 comments

Thomas commented on Nov 24, 2020

Hi, I have set the value to "decimals" => 2 in the column. That was working fine till yesterday. After the update from 4.7.1 to 5 yesterday the column values show the whole number.

David Winterburn commented on Nov 24, 2020

Hi Thomas,

Please open the file koolreport/datagrid/DataTables.php and replace the whole function buildDataRows with this one:

    protected function buildDataRows($rowType = 'assoc')
    {
        $this->dataRows = [];
        $this->dataStore->popStart();
        while ($row = $this->dataStore->pop()) {
            $dataRow = [];
            foreach ($this->showColumnKeys as $ci => $cKey) {
                $cMeta = Util::get($this->cMetas, $cKey, []);
                $formatValue = Util::get($cMeta, "formatValue", null);
                $key = ($rowType === 'assoc') ? $cKey : $ci;
                if (isset($row[$cKey]) || is_callable($formatValue)) {
                    $value = ($cKey !== "#") ?
                        Util::get($row, $cKey, $this->emptyValue) 
                        : ($ci + $cMeta["start"]);
                    ob_start();
                    echo $this->formatValue($value, $cMeta, $row, $cKey);
                    $dataRow[$key] = ob_get_clean();
                }
                else {
                    $dataRow[$key] = $this->emptyValue;
                }
            }
            $this->dataRows[] = $dataRow;
        }
    }
Thomas commented on Nov 24, 2020

It is working. Thanks a lot for the quick fix.

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
bug
solved

DataGrid