KoolReport's Forum

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

Group By not working with Data tables in export to PDF. #3457

Open iWorQ Systems opened this topic on on Sep 25 - 4 comments

iWorQ Systems commented on Sep 25

I am trying to get our export to PDF. we are using the PhantomJs export option and when we try to use the group by it breaks the report on the export. if I take off the clientRowGroup then the report is fine.

also if I turn off fast render it also gets the report back but it does not group it.

here is the code, and what I am geting back.

DataTables::create([
                'name' => 'rowGroupTable',
                'dataStore' => $this->dataStore('result'),
                'clientRowGroup' => [
                    'groupby' => [
                        'direction' => 'asc',
                        'top' => '<td colspan="999">' . $groupbyTitle . ': {groupby}</td>',
                    ],
                ],
                'cssClass' => [
                    'table' => 'table table-bordered table-striped table-hover'
                ],
                'columns' => $columns,
                'showFooter' => $this->params['sum'],
                'fastRender' => true,
            ]);

With Group By:

Without Group By:

Without fastRender:

Sebastian Morales commented on Sep 26

The RowGroup js plugin of DataTables might not be compatible with Export package's phantomJS engine. Pls test row group with CloudExport to see if it works or not.

iWorQ Systems commented on Sep 29

We need it to be PhantomJs for this project, so I just changed to use Tables instead of datatables and its working fine.

iWorQ Systems commented 4 days ago

We are having an issue with data tables with the row detail as well. Is that due to us using PhantomJs?

$columns['{rowDetailData}'] = ['visible' => false,];

        DataTables::create([
            'name' => 'rowDetailTable',
            'dataStore' => $this->dataStore('result'),
            'fastRender' => true,
            'cssClass' => [
                'table' => 'table table-bordered table-striped table-hover'
            ],
            'columns' => $columns,
            'showFooter' => $this->params['sum'],
            'rowDetailData' => function ($row) {
                $html = '';
                $empty = true;
                foreach ($this->params['detailArr'] as $details) {
                    $detail =
                    !$this->dataStore($details['paramName'])->isEmpty()
                    ? $this->dataStore($details['paramName'])->filter($details['instance'], '=', $row['identifier'])
                    : $this->dataStore('inspectionDetails');
                    if (!$detail->isEmpty()) {
                        $empty = false;
                        $html .= ' <h4 class="underlineBold">' . $details['detailname'] . '</h4>' .
                        Table::create([
                            'dataSource' => $this->dataStore($details['paramName'])->filter(
                                $details['instance'],
                                '=',
                                $row['identifier']
                            ),
                            'cssClass' => [
                                'table' => 'tablewidth table-bordered table-striped table-hover',
                                'td' => 'tdcolor'
                            ],
                            'excludedColumns' => [$details['instance']]
                        ], true);
                    }
                }
                $this->params['detailCount'] += 1;
                if (!$empty) {
                    array_push($this->params['detailCountArray'], $this->params['detailCount']);
                    $empty = true;
                }
                return $html;
            },
            'onReady' => "function() {
                let x = getDetails();
                rowDetailTable.on( 'draw', function () {
                    let num = 0
                    x = getDetails();
                    x.forEach(function(i) {
                        let actual = i;
                        KRrowDetailTable.expandRowDetail(actual);
                    })
                    redraw();
                } );
                x.forEach(function(i) {
                    let actual = i;
                    KRrowDetailTable.expandRowDetail(actual);
                })
                redraw();
                // KRrowDetailTable.expandAllRowDetails();
            }",
        ]);

this is the code and its just not working.

If i take out the ON ready it shows the report but none of the rows are open.

Even If I just do

"onReady" => "function() {

    rowDetailTable.on( 'draw', function () {
        KRrowDetailTable.expandAllRowDetails();
    } );
    KRrowDetailTable.expandAllRowDetails();
}",

it still does not work. they wont expand on Phantomjs

With My js logic

With your Js Logic

Sebastian Morales commented 2 days ago

DataTables row detail is a feature based on usage of DataTables client-side javascript API calls, the latest of which probably can't work on PhantomJS engine in Export package. We will add server-side row detail feature to DataTables road map.

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

Export