Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DataTable As A Service PDF Not working #3060

Closed
yhagus opened this issue Sep 7, 2023 · 2 comments
Closed

DataTable As A Service PDF Not working #3060

yhagus opened this issue Sep 7, 2023 · 2 comments

Comments

@yhagus
Copy link

yhagus commented Sep 7, 2023

Summary of problem or feature request

image
image

I'm currently using Yajra DataTables 10 on Laravel 10 and I'm facing this problem when I tried Export As PDF (Laravel Snappy, I've installed wkhtmltopdf via composer also.

Code snippet of problem

PHP Controller File

public function index(DeviceDataTable $dataTable)
{
    return $dataTable->render('pages.device.index');
}

PHP Service file:

public function html(): HtmlBuilder
    {
        return $this->builder()
            ->setTableId('device-table')
            ->columns($this->getColumns())
            ->minifiedAjax()
            ->autoWidth(false)
            ->orderBy(0)
            ->buttons([
                Button::make('excel'),
                Button::make('csv'),
                Button::make('pdf'),
                Button::make('print'),
//                Button::make('reset'),
                Button::make('reload')
            ]);
    }

main.js

$(document).ready(function(){
    $.extend(true, DataTable.defaults, {
        dom:
            "<'row'<'col-sm-12 mb-4'B>>" +
            "<'row'<'col-sm-12 col-md-6'l><'col-sm-12 col-md-6'f>>" +
            "<'row'<'col-sm-12'tr>>" +
            "<'row'<'col-sm-12 col-md-5'i><'col-sm-12 col-md-7'p>>",
    });

    $.extend(true, DataTable.Buttons.defaults, {
        dom: {
            buttonLiner: {
                tag: ''
            },
        },
    });

    $.extend(DataTable.ext.classes, {
        sTable: "table table-bordered table-hover dataTable",
    });
})

System details

I modified the laravel-datatables-vite package into my needs, which is removing the jquery and bootstrap and changed it to match my app theme accordingly (Bootstrap 4.6 and jQuery 3.6)

  • Windows
  • PHP 8.1
  • Laravel 10
  • Laravel-Datatables 10
@yajra
Copy link
Owner

yajra commented Sep 13, 2023

Seems like an issue with snappy package, see barryvdh/laravel-snappy#512.

@yhagus
Copy link
Author

yhagus commented Sep 13, 2023

Thanks, it's fixed.
Solution was to keep "knplabs/knp-snappy": "1.4.1" (install that specific version if you don't have one) in composer.json. ^1.43 still has problems with it.

@yhagus yhagus closed this as completed Sep 13, 2023
@github-actions github-actions bot locked and limited conversation to collaborators Sep 28, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants