yajra / laravel-datatables-buttons

Laravel DataTables Buttons Plugin
https://yajrabox.com/docs/laravel-datatables/buttons-installation
MIT License
254 stars 53 forks source link

Not able make the print and export buttons work #9

Closed arieltoledo closed 7 years ago

arieltoledo commented 7 years ago

Hi, i have installed snappy and wkhtmltopdf. wkhtmltopdf its working on terminal. Configure the datatables config with


return [
    /**
     * DataTables internal index id response column name.
     */
    'index_column'    => 'DT_Row_Index',

    /**
     * Namespaces used by the generator.
     */
    'namespace'       => [
        /**
         * Base namespace/directory to create the new file.
         * This is appended on default Laravel namespace.
         * Usage: php artisan datatables:make User
         * Output: App\DataTables\UserDataTable
         * With Model: App\User (default model)
         * Export filename: users_timestamp
         */
        'base'  => 'DataTables',

        /**
         * Base namespace/directory where your model's are located.
         * This is appended on default Laravel namespace.
         * Usage: php artisan datatables:make Post --model
         * Output: App\DataTables\PostDataTable
         * With Model: App\Post
         * Export filename: posts_timestamp
         */
        'model' => '',
    ],

    /**
     * PDF generator to be used when converting the table to pdf.
     * Available generators: excel, snappy
     * Snappy package: barryvdh/laravel-snappy
     * Excel package: maatwebsite/excel
     */
    'pdf_generator'   => 'snappy',

    /**
     * Snappy PDF options.
     */
    'snappy'          => [
        'options'     => [
            'no-outline'    => true,
            'margin-left'   => '0',
            'margin-right'  => '0',
            'margin-top'    => '10mm',
            'margin-bottom' => '10mm',
        ],
        'orientation

But when I try to print I get

**Forbidden

You don't have permission to access /&draw=1&columns[0][data]=title&columns[0][name]=title&columns[0][searchable]=true&columns[0][orderable]=true&columns[0][search][value]=&columns[0][search][regex]=false&columns[1][data]=location.title&columns[1][name]=location.title&columns[1][searchable]=true&columns[1][orderable]=true&columns[1][search][value]=&columns[1][search][regex]=false&columns[2][data]=estado&columns[2][name]=status.title&columns[2][searchable]=true&columns[2][orderable]=true&columns[2][search][value]=&columns[2][search][regex]=false&columns[3][data]=date&columns[3][name]=date&columns[3][searchable]=true&columns[3][orderable]=true&columns[3][search][value]=&columns[3][search][regex]=false&columns[4][data]=action&columns[4][name]=action&columns[4][searchable]=false&columns[4][orderable]=false&columns[4][search][value]=&columns[4][search][regex]=false&order[0][column]=0&order[0][dir]=asc&start=0&length=10&search[value]=&search[regex]=false&action=print on this server.**

with this url

/&draw=1&columns%5B0%5D%5Bdata%5D=title&columns%5B0%5D%5Bname%5D=title&columns%5B0%5D%5Bsearchable%5D=true&columns%5B0%5D%5Borderable%5D=true&columns%5B0%5D%5Bsearch%5D%5Bvalue%5D=&columns%5B0%5D%5Bsearch%5D%5Bregex%5D=false&columns%5B1%5D%5Bdata%5D=location.title&columns%5B1%5D%5Bname%5D=location.title&columns%5B1%5D%5Bsearchable%5D=true&columns%5B1%5D%5Borderable%5D=true&columns%5B1%5D%5Bsearch%5D%5Bvalue%5D=&columns%5B1%5D%5Bsearch%5D%5Bregex%5D=false&columns%5B2%5D%5Bdata%5D=estado&columns%5B2%5D%5Bname%5D=status.title&columns%5B2%5D%5Bsearchable%5D=true&columns%5B2%5D%5Borderable%5D=true&columns%5B2%5D%5Bsearch%5D%5Bvalue%5D=&columns%5B2%5D%5Bsearch%5D%5Bregex%5D=false&columns%5B3%5D%5Bdata%5D=date&columns%5B3%5D%5Bname%5D=date&columns%5B3%5D%5Bsearchable%5D=true&columns%5B3%5D%5Borderable%5D=true&columns%5B3%5D%5Bsearch%5D%5Bvalue%5D=&columns%5B3%5D%5Bsearch%5D%5Bregex%5D=false&columns%5B4%5D%5Bdata%5D=action&columns%5B4%5D%5Bname%5D=action&columns%5B4%5D%5Bsearchable%5D=false&columns%5B4%5D%5Borderable%5D=false&columns%5B4%5D%5Bsearch%5D%5Bvalue%5D=&columns%5B4%5D%5Bsearch%5D%5Bregex%5D=false&order%5B0%5D%5Bcolumn%5D=0&order%5B0%5D%5Bdir%5D=asc&start=0&length=10&search%5Bvalue%5D=&search%5Bregex%5D=false&action=print
arieltoledo commented 7 years ago

So this its the thing. Reset an reload are working great with the url -> http://metas.54/cabinets?draw.
But when i hit the print button url changes to http://metas.54/&draw and this its not working. If I manually add http://metas.54/cabinets?draw it works.

yajra commented 7 years ago

Can you please paste your builder parameters? What did you use as ajax url?

Seems to work well as per demo: http://dt54.yajrabox.com/buttons/eloquent http://dt54.yajrabox.com/buttons/query

arieltoledo commented 7 years ago

That was the problem ajax('') was empty once I added ajax('/cabinets?') everything works like a charm. Thanks @yajra you're the best.