laravel-datatables-editor icon indicating copy to clipboard operation
laravel-datatables-editor copied to clipboard

Export buttons server side in excel,csv, pdf on dataTable

Open ELIDJEAKA opened this issue 7 years ago • 1 comments

Summary of problem or feature request

Hi, I work on a project where I'm using DataTable with laravel but when I would like export data filter or all data, the export give me view data tables export. I would like to export data server side and data filter in my datatable plugin in csv and excel plugin... Need some helps please / Thanks you ...

Code snippet of problem

this is my view code

<script> $(function() { $('#table').DataTable({ responsive: true, fixedColumns: true, fixedHeader: true, dom: 'Bfrtip', buttons: [ 'colvis','csv', 'excel', 'print', { extend: 'pdfHtml5', orientation: 'landscape', pageSize: 'LEGAL' } ], processing: true, serverSide: true, ajax: '{!! route('banks.data') !!}', columns: [ { data: 'action', name: 'action', orderable: false, searchable: false}, { data: 'BANK_COUNTRY', name: 'BANK_COUNTRY' }, { data: 'BANK_NAME', name: 'BANK_NAME' }, { data: 'ALTERNATE_BANK_NAME', name: 'ALTERNATE_BANK_NAME' }, { data: 'SHORT_BANK_NAME', name: 'SHORT_BANK_NAME' }, { data: 'BANK_NUMBER', name: 'BANK_NUMBER' }, { data: 'DESCRIPTION', name: 'DESCRIPTION' }, { data: 'TAX_PAYER_ID', name: 'TAX_PAYER_ID' }, { data: 'TAX_REGISTRATION_NUMBER', name: 'TAX_REGISTRATION_NUMBER' }, { data: 'INACTIVE_ON', name: 'INACTIVE_ON' }, { data: 'CONTEXT_VALUE', name: 'CONTEXT_VALUE' }, { data: 'ADDRESS', name: 'ADDRESS' }, { data: 'CONTACT', name: 'CONTACT' }, { data: 'CREATION_DATE', name: 'CREATION_DATE' } ], initComplete: function () { this.api().columns().every(function () { var column = this; var input = document.createElement('input'); $(input).appendTo($(column.footer()).empty()) .on('change', function () { var val = $.fn.dataTable.util.escapeRegex($(this).val()); column.search($(this).val(), false, false, true).draw(); }); }); } }); }); </script>

this is my controller code

`<?php namespace App\Http\Controllers\Admin; use Illuminate\Http\Request; use App\Http\Controllers\Controller; use App\bank; use App\bank_branches; use App\bank_accounts; use Yajra\Datatables\DataTables;

class bankController extends Controller { function __construct() { $this->middleware('permission:bank-list'); } /** * Display a listing of the resource. * * @return \Illuminate\Http\Response */ public function index() {

    //$banks = bank::all();
    return view('admin.bank.index');
}
   public function banksList(){
    $banks = \DB::table('banks')->select();
    return DataTables::of($banks)
    ->addColumn('action', function ($banks) {
        #return '<a href="gl-data/JV_BATCH_NAME'.$gl_data->DOCUMENT_NUMBER.'" class="btn btn-icons btn-rounded btn-outline-success" title="Plus de détails"><i class="mdi mdi-loupe"></i>';
        return '<a href="banks/BANK_COUNTRY/'.$banks->BANK_COUNTRY."/BANK_NAME/".$banks->BANK_NAME."/BANK_ID/".$banks->id.'" class="btn btn-icons btn-rounded btn-outline-success" title="Plus de détails"><i class="mdi mdi-loupe"></i></a>';
    })
    ->make(true);
}`

System details

  • Windows 10
  • PHP 7.2.0
  • Laravel 5.6
  • Laravel-DataTables Oracle 8.7

ELIDJEAKA avatar Aug 27 '18 11:08 ELIDJEAKA

You can use this package https://github.com/yajra/laravel-datatables-buttons.

See docs https://yajrabox.com/docs/laravel-datatables/master/buttons-installation for ref.

yajra avatar Sep 18 '18 02:09 yajra

This issue is stale because it has been open for 30 days with no activity. Remove stale label or comment or this will be closed in 7 days.

github-actions[bot] avatar Mar 26 '24 00:03 github-actions[bot]

This issue was closed because it has been inactive for 7 days since being marked as stale.

github-actions[bot] avatar Apr 02 '24 00:04 github-actions[bot]