i am using yajra data tables for server side data-tables my controller is this
public static function alleventsData(Request $request)
{
$limit = intVal($request->input('length'));
$start = $request->input('start');
$meta = EventsRepository::showMeta();
$totalRecords = $meta[1][1]['Value'];
$offset = intVal($start);
$allEvents = EventsRepository::allEvents($offset, $limit);
return Datatables::collection($allEvents)
->addColumn(
'parent',
function ($allEvents) {
return $allEvents['category_name'];
}
)
->addColumn(
'venueName',
function ($allEvents) {
return $allEvents['venue_name'];
}
)
->addColumn(
'venueLocation',
function ($allEvents) {
return $allEvents['location'];
}
)
->addColumn(
'occurs_at',
function ($allEvents) {
return $allEvents['occurs_at'];
}
)
->addColumn(
'hot_popular_main',
function ($allEvents) {
return '<input type="checkbox" name="hot_popular_main" class= "updatePopertyEvent" attr="hot_popular_main" id="'.$allEvents['id'].'" value="'.$allEvents['hot_popular_main'].'" '.($allEvents['hot_popular_main']==1?'checked="checked"':'').'/>';
}
)
->addColumn(
'synchronize',
function ($allEvents) {
return '<button value="'.$allEvents['id'].'" class="btn btn-info synchronize" >Synchronize</button>';
}
)
->addColumn(
'status',
function ($allEvents) {
$status = $allEvents['status']==1?"Active":"Deactive";
return '<button value="'.$allEvents['id'].'" class="btn btn-info status" data-attr="'.$allEvents['status'].'">'.$status.'</button>';
}
)
->with(['recordsTotal'=>$totalRecords, 'recordsFiltered'=>$totalRecords])
->make(true);
}
and my js is this
$(function() {
$('.eventTableAll').DataTable({
processing: true,
serverSide: true,
ajax: '{!! route('datatables.alleventsData') !!}',
columns: [
{ data: 'event_name', name: 'event_name' },
{ data: 'parent', name: 'parent', searchable: true },
{ data: 'venueName', name: 'venueName', searchable: true },
{ data: 'venueLocation', name: 'venueLocation', searchable: true },
{ data: 'occurs_at', name: 'occurs_at', searchable: true },
{ data: 'hot_popular_main', name: 'hot_popular_main' },
{ data: 'synchronize', name: 'synchronize' },
{ data: 'status', name: 'status' }
]
});
});
but problem is when i move to next page like on second it does not get any data , i have seen console that it is getting data but not embedded in data-tables data index .
from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/1U39A0r
via IFTTT
Aucun commentaire:
Enregistrer un commentaire