I have a Problem with the Pagenation and the Showing Text. The Table has only 3 Entries and the Pagenation show me " Previous 1 2 3 4 5 ... next" - Buttons. The 3 entries are shown in the tables. I can selected and editing the entries. On the left line in the Pagenation Line are following text: Showing 0 to 0 of 0 entries (filtered from NaN total entries)1 row selected. I use the last Version of Datatables, editor, Buttons, Select with bootstrap support. The Datatables debugger: http://debug.datatables.net/egoqed
Thanks for Helps
Andreas
my JS code is this:
$(document).ready(function(){
$('<div class="loading">Loading</div>').appendTo('body');
editor = new $.fn.dataTable.Editor({
ajax: 'assets/lib/ev_server_processing.php',
table: '#athletelist',
fields: [{
label: 'First name:',
name: 'firstname'
},{
label: 'Last name:',
name: 'lastname'
},{
label: 'Name Prefix:',
name: 'nameprefix'
},{
label: 'Birthday:',
name: 'birthday',
type: 'datetime'
},{
label: 'Nationality:',
name: 'nation',
type: 'select'
},{
label: 'Reg ID:',
name: 'regid'
}]
});
var table = $('#athletelist').DataTable({
initComplete: function(settings, json){
$('div.loading').remove();
table.buttons().container().appendTo($('#athletelist_wrapper .col-sm-6:eq(0)'));
},
lengthChange: false,
processing: true,
serverSide: true,
ajax: 'assets/lib/ev_server_processing.php',
autoWidth: false,
columns: [
{ data: null, render: function(data, type, row){
if(!data.nameprefix){
name = data.lastname+', '+data.firstname;
}else{
name = data.nameprefix+' '+data.lastname+', '+data.firstname;
}
return name;
}, width: '20%' },
{ data: 'birthday'},
{ data: null, render: function(data, type, row){
age = getAge(data.birthday, '');
return age.years;
}},
{ data: 'nation'},
{ data: 'regid'},
{ data: 'id'},
{ data: null, defaultContent: '', orderable: false},
{ data: null, defaultContent: '', orderable: false}
],
select: true,
buttons: [
{ extend: 'create', editor: editor },
{ extend: 'edit', editor: editor },
{ extend: 'remove', editor: editor },
{ extend: 'collection', text: 'Export',
buttons: [
{ extend: 'copyHtml5', ClassName: 'btn btn-sm btn-default', text: '<i class="fa fa-files-o"></i>', titleAttr: 'Copy'},
{ extend: 'excelHtml5', ClassName: 'btn btn-sm btn-default', text: '<i class="fa fa-file-excel-o"></i>', titleAttr: 'Excel'},
{ extend: 'csvHtml5', ClassName: 'btn btn-sm btn-default', text: '<i class="fa fa-file-text-o"></i>', titleAttr: 'CSV'},
{ extend: 'pdfHtml5', ClassName: 'btn btn-sm btn-default', text: '<i class="fa fa-file-pdf-o"></i>', titleAttr: 'PDF'},
{ extend: 'colvis', ClassName: 'btn btn-sm btn-default', text: '<i class="fa fa-list-ul"></i>', titleAttr: 'Column visibility'}
]
}
]
});
});
server side Code:
if((include PLUGIN_DIR.'DTables/Editor/1.5.6/php/DataTables.php') == FALSE){ echo 'Failed include Edit'; }
use
DataTables\Editor,
DataTables\Editor\Field,
DataTables\Editor\Format,
DataTables\Editor\Mjoin,
DataTables\Editor\Upload,
DataTables\Editor\Validate;
Editor::inst( $db, 'entries_test' )
->fields(
Field::inst( 'id' ),
Field::inst( 'firstname' )->validator( 'Validate::notEmpty' ),
Field::inst( 'lastname' )->validator( 'Validate::notEmpty' ),
Field::inst( 'nameprefix' ),
Field::inst( 'birthday' )
->validator( 'Validate::dateFormat', array(
"format" => Format::DATE_ISO_8601,
"message" => "Please enter a date in the format yyyy-mm-dd"
))
->getFormatter( 'Format::date_sql_to_format', Format::DATE_ISO_8601 )
->setFormatter( 'Format::date_format_to_sql', Format::DATE_ISO_8601 ),
Field::inst( 'nation' )->validator( 'Validate::notEmpty' ),
Field::inst( 'regid' )
)
->process( $_POST )
->json();