In relation to issue #341 discussions.
Have you changed/implemented this post method changes?
When will you implement POST method as its not working with Export options(pdf, xls, csv)?
Currently GET method is used. When i change it to POST, so for export option page stays blank.
Thanks
@nikunjkabariya this is not yet implemented. If you can, PR's are welcome. Thanks!
really could use this.. it's causing me a lot of pain :(
@mastrip2 Just nailed it; changed my initialization as follow.
var tableIndex=$('#tableIndex').DataTable({
"order": [[ 0, "asc" ]],
"aLengthMenu": [[5, 10, 25], [5, 10, 25]],
"iDisplayLength": 10,
"dateFormat": 'yyyy-mm-dd',
"processing": true,
"serverSide": true,
"ajax": {
'url': '{{route("clinics.api.laboratoryIndex")}}',
'type': 'POST',
'headers': {
'X-CSRF-TOKEN': '{{ csrf_token() }}'
}
},
"columns":[
{data: 'products', name: 'products'},
],
"columnDefs": [
{ "searchable": false, "bSortable": false, "targets": 0 }
],
language: {
"sProcessing": "Procesando...",
"sLengthMenu": "Mostrar MENU registros",
"sZeroRecords": "No se encontraron resultados",
"sEmptyTable": "Ningún dato disponible en esta tabla",
"sInfo": "Mostrando registros del START al END de un total de TOTAL registros",
"sInfoEmpty": "Mostrando registros del 0 al 0 de un total de 0 registros",
"sInfoFiltered": "(filtrado de un total de MAX registros)",
"sInfoPostFix": "",
"sSearch": "Buscar: ",
"sUrl": "",
"sInfoThousands": ",",
"sLoadingRecords": "Cargando...",
"oPaginate": {
"sFirst": "Primero",
"sLast": "Último",
"sNext": "Siguiente",
"sPrevious": "Anterior"
},
"oAria": {
"sSortAscending": ": Activar para ordenar la columna de manera ascendente",
"sSortDescending": ": Activar para ordenar la columna de manera descendente"
}
}
});
I guess the problem is how long get parameters are; thus POST hasnt come in trouble
@gadius Using the default implementation of this package "as a service", can you explain where you made these modifications?
my table.blade.php simply holds
<style>
th, td { white-space: nowrap; }
</style>
{!! $dataTable->table(['width' => '100%']) !!}
@push('scripts')
<link rel="stylesheet" href="https://cdn.datatables.net/buttons/1.0.3/css/buttons.dataTables.min.css">
<script src="https://cdn.datatables.net/buttons/1.0.3/js/dataTables.buttons.min.js"></script>
<script src="/vendor/datatables/buttons.server-side.js"></script>
{!! $dataTable->scripts() !!}
@endpush
So not sure where I'm supposed to add your modification to make this work.
Did you have to edit one of your template stub files? Would you mind sharing if so, thanks
@vesper8 You should make a table on your view and use the javascript i posted to make it work.
Duplicate and will be implemented on #826 .
I have very simple fix.
In service implementation html builder method
```php
public function html()
{
$table = $this->builder()
->columns($this->getColumns())
->ajax(['type' => 'POST', 'data' => '{"_method":"GET"}']);
$table->addAction(['width' => '80px']);
return $table->parameters($this->getBuilderParameters());
}
`
This working for its just 'X-CSRF-TOKEN': '{{ csrf_token() }}' in laravel 5.3 and datatable 6.*
````
$('#payments').dataTable({
processing: true,
serverSide: true,
"ajax": {
url: '{{ Url('payments_history_table')}}',
type:'POST',
'headers': {
'X-CSRF-TOKEN': '{{ csrf_token() }}'
},
'data':dataInfo,
},
"columns": [
{ data: 'payment_id', name : 'payment_id'},
{ data: 'transactions_id', name : 'transactions_id'},
{"data": 'amount', "name": 'amount'},
{"data": 'allowed_payment_methods_id', "name": 'allowed_payment_methods_id'},
{"data": 'user_id', "name": 'user_id'},
{"data": 'guest_donation_id', "name": 'guest_donation_id'},
{"data": 'transactions_types_id', "name": 'transactions_types_id'},
{"data": 'created_at', "name": 'created_at'},
{"data": 'updated_at', "name": 'updated_at'}
],
"columnDefs": [
{ "searchable": false, "bSortable": false, "targets": 0 }
],
});
```
@herzcthu I just noticed today your solution. Nice tip and a clever one. Thanks!
@anik587 I usually set this token globally.
// Laravel ajax-token integration
var _token = $('meta[name="csrf-token"]').attr('content');
$.ajaxSetup({
headers: {
'X-CSRF-TOKEN': _token
}
});
http://datatables.net/tn/7 Error is fixed By Adding 'X-CSRF-TOKEN': '{{ csrf_token() }}' this as gven below
$('#payments').dataTable({
processing: true,
serverSide: true,
"ajax": {
url: '{{ Url('payments_history_table')}}',
type:'POST',
'headers': {
'X-CSRF-TOKEN': '{{ csrf_token() }}'
},
'data':dataInfo,
},
"columns": [
{ data: 'payment_id', name : 'payment_id'},
{ data: 'transactions_id', name : 'transactions_id'},
{"data": 'amount', "name": 'amount'},
{"data": 'allowed_payment_methods_id', "name": 'allowed_payment_methods_id'},
{"data": 'user_id', "name": 'user_id'},
{"data": 'guest_donation_id', "name": 'guest_donation_id'},
{"data": 'transactions_types_id', "name": 'transactions_types_id'},
{"data": 'created_at', "name": 'created_at'},
{"data": 'updated_at', "name": 'updated_at'}
],
"columnDefs": [
{ "searchable": false, "bSortable": false, "targets": 0 }
],
});
Most helpful comment
I have very simple fix.
In service implementation html builder method
```php
public function html()
{
$table = $this->builder()
->columns($this->getColumns())
->ajax(['type' => 'POST', 'data' => '{"_method":"GET"}']);
`