KoolReport's Forum

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

DataTable header grouping #1758

Open Thomas opened this topic on on Dec 14, 2020 - 3 comments

Thomas commented on Dec 14, 2020

Hi, I am looking for a way to group headers. The regular table has an option for that, but I can't figure out how to do that with the "complexHeader" or the "headCallback" function. I like the complexHeader but how do I label the columns? Only the column names are shown with this option but not the labels.

Sebastian Morales commented on Dec 16, 2020

Thomas, we will add support for DataTables' complexHeader option to work with columns' label. Meanwhile you could clone the current columns to new columns using your labels and use complex header on those new columns. For example:

    //MyReport.php
    $myColumns = ...
    ...
    ->pipe(new \koolreport\processes\Map(array(
        "{value}" => function($row) use ($myColumns) {
            foreach ($myColumns as $col) {
                $newCol = changeColToLabel($col);
                $row[$newCol] = $row[$col];
            }
            return $row;
        }
    )))

    //MyReport.view.php
    DataTables::create(array(
        //use new columns with complex header
    ));        
Thomas commented on Dec 17, 2020

Is there an other way at this moment?

My DataTable uses accumulative data which I generated through a for-loop in the view. I can't use this mehtod on a datastore, so that won't work for me.

Sebastian Morales commented on Dec 18, 2020

Can you post your column names and labels so I have an idea of how you intend to use complex headers?

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

DataGrid