waldo2188 / DatatableBundle

Symfony2 Ajax Datatable Bundle to simplify the use of http://datatables.net/ (and Doctrine entity inside)
MIT License
17 stars 16 forks source link

Records are not formatted #16

Open DMoneyEva opened 7 years ago

DMoneyEva commented 7 years ago

This is how my records came out

{"draw":0,"recordsTotal":"1","recordsFiltered":"1","data":[["Hillary","Test",1]]}

What is causing this problem?

necrophidia commented 6 years ago

i do a temprorary fix by editing file /Util/Datatable.php by adding:

$formattedData = [];
        $fieldNames = $this->getFields();
        foreach ($data as $value) {
            $formattedRow = [];
            $loopIndex = 0;
            foreach ($fieldNames as $fieldKey => $fieldValue) {
                $formattedRow[$fieldKey] = $value[$loopIndex];
                $loopIndex += 1;
            }
            array_push($formattedData, $formattedRow);
        }
        $data = $formattedData;

inside execute() function, in line after array_walk($data, function($val, $key) use ($id_index, &$ids)