I have this little problem with the datatables, I can not put the elements to export
Try using this example Datatables Export
But I could not, I use laravel 5.5
and well this is what I have
This is my driver
use Illuminate\Http\Request;
use Datatables;
use App\Usuario;
use DB;
class DataTablesController extends Controller
{
/**
* Displays datatables front end view
*
* @return \Illuminate\View\View
*/
public function datatable()
{
return view('usuarios.resultado');
}
public function getPosts()
{
$model = Usuario::query();
// return datatables()->eloquent(Usuario::query())->toJson();
return Datatables::eloquent($model)
->addColumn('action', function($user) {
return '
<br><a href="' . route('VerResultado', $user->id_usu) . '" class="btn btn-xs btn-success" title="Detalles">Ver Detalles</a>
';
})
->toJson();
}
}
and this is in the ajax
<script>
$(document).ready( function () {
$('#users').DataTable({
dom: 'Bfrtip',
buttons: [
'copy', 'csv', 'excel', 'pdf', 'print'
],
"procesing": true,
"serverside": true,
responsive: true,
"ajax": '{{ route('datatable/getdata') }}',
"columns":[
{data: 'id_usu', name: 'id_usu'},
{data: 'nombre', name: 'nombre'},
{data: 'email', name: 'email'},
{data: 'edad', name: 'edad'},
{data: 'sexo', name: 'sexo'},
{data: 'escolaridad', name: 'escolaridad'},
{data: 'photo', name: 'photo',
render: function(data, type, full, meta){
return "<img src=\"/imageuser/"+data+"\" height=\"60\"/>";
}
},
{data: 'created_at', name: 'created_at'},
{data: 'action', name: 'action', orderable: false, searchable: false},
],
order: [[1, 'asc']]
});
});
</script>
I do not know if I have to see anything but these are my scripts that I have on the page
{{ Html::script('/js/jquery.min.js') }}
{{ Html::script('/js/app.js') }}
{{ Html::script('/js/datatable.js') }}
{{ Html::script('/js/dataTables.buttons.min.js') }}
{{ Html::script('/js/buttons.flash.min.js') }}
{{ Html::script('/js/jszip.min.js') }}
{{ Html::script('/js/buttons.print.min.js') }}
{{ Html::script('/js/buttons.html5.min.js') }}
{{ Html::script('/js/vfs_fonts.js') }}
{{ Html::script('/js/pdfmake.min.js') }}
{{ Html::script('/js/jquery3.3.1.min.js') }}
{{ Html::script('/js/bootstrap.min.js') }}
{{ Html::script('/js/jquery-3.3.1.slim.min.js') }}
{{ Html::script('/js/popper.min.js') }}
{{ Html::script('/js/jquery-3.3.1.js') }}
{{ Html::script('/js/jquery.dataTables.js') }}
{{ Html::script('/js/popper.min.js') }}
{{ Html::script('/js/all.js') }}
{{ Html::script('/js/Chart.min.js') }}
{{ Html::script('/js/Chart.bundle.min.js') }}
{{ Html::script('https://unpkg.com/jspdf@latest/dist/jspdf.min.js') }}
I still can not understand how the export functions works, maybe I'm doing something wrong or I do not know how to return those buttons or the function as such, I hope you can help me, thanks
Edit: code css
{{ Html::style('/css/bootstrap.min.css') }}
{{ Html::style('/css/app.css') }}
{{ Html::style('/css/jquery.dataTables.css') }}
{{ Html::style('/css/zoom.css') }}
{{ Html::style('/css/jquery.dataTables.min.css') }}
{{ Html::style('/css/all.css') }}
{{ Html::style('/css/buttons.dataTables.min.css') }}