yajra / laravel-datatables

jQuery DataTables API for Laravel
https://yajrabox.com/docs/laravel-datatables
MIT License
4.74k stars 862 forks source link

how i can pass data into new page transactions.print #3172

Open Mohamed-Elaraby opened 2 weeks ago

Mohamed-Elaraby commented 2 weeks ago
          The print options should be modified via print preview by overriding the default view used in printing.
class TransactionsDataTable extends DataTable
{
    protected $printPreview = 'transactions.print';
...

Copy resources/views/vendor/datatables/print.blade.php content to resources/views/transactions/print.blade.php and append any necessary info you wanted to print.

Originally posted by @yajra in https://github.com/yajra/laravel-datatables/issues/759#issuecomment-248494798

yajra commented 2 weeks ago

At the moment, you can override the method getDataForPrint or the printPreview.

    public function printPreview(): Renderable
    {
        $data = $this->getDataForPrint();

        return view($this->printPreview, compact('data'));
    }

    /**
     * Get mapped columns versus final decorated output.
     */
    protected function getDataForPrint(): array
    {
        $columns = $this->printColumns();

        return $this->mapResponseToColumns($columns, 'printable');
    }