Hello,
I have an error and can't find the solution.
The error is:
DataTables warning: table id=tm_adoptanten_search - Requested unknown parameter 'tm_adoptanten.id' for row 0, column 0. For more information about this error, please see http://datatables.net/tn/4
Here is the script
(function($){
$(document).ready(function() {
$.fn.dataTable.moment( 'DD.MM.YYYY' );
var table = $('#tm_adoptanten_search').DataTable( {
"serverSide": true,
//"dom": '<"bRight"B><"bLeft"f><t><ip>',
//dom: '<"clear"><"bRight"B><"clear"><"bLeft"l>frtip',
dom: '<"bRight"B><"bLeft"f>l<t><ip>',
colReorder: true,
stateSave: true,
stateDuration: 0,
stateSaveCallback: function(settings,data) {
localStorage.setItem( 'tm_adoptanten_search' + settings.sInstance, JSON.stringify(data) )
},
stateLoadCallback: function(settings) {
return JSON.parse( localStorage.getItem( 'tm_adoptanten_search' + settings.sInstance ) )
},
buttons: [
{
extend: 'colvis',
collectionLayout: 'fixed three-column',
postfixButtons: [ 'colvisRestore' ],
columns: ':not(:first-child)'
}
],
language: {
buttons: {
colvis: "Anzuzeigende Spalten",
colvisRestore: "Zurücksetzen"
},
paginate: {
first: "Erste",
last: "Letzte",
next: "Weiter",
previous: "Zurück"
},
search: "Suchen:",
info: "Zeige _START_ bis _END_ von _TOTAL_ Einträgen",
infoEmpty: "Zeige 0 bis 0 von 0 Einträgen",
decimal: ",",
thousands: ".",
lengthMenu: "Zeige _MENU_ Einträge",
loadingRecords: "Loading...",
processing: "Bitte warten...",
zeroRecords: "Keine Einträge gefunden"
},
"info": true,
"searching": true,
"responsive": false,
"bAutoWidth": true,
"sPaginationType": "full_numbers",
"scrollX": true,
"columnDefs": [
{
"targets": [ 0 ],
"visible": true,
"searchable": false
}
],
ajax: {
url: "adopt_search_processing.php?suche=<?php echo $gsearch; ?>",
type: "POST"
},
columns: [
{
data: "tm_adoptanten.id"
},
{
data: "tm_anrede.Anrede"
},
{
data: "tm_titel.Titel"
},
{
data: "tm_adoptanten.Name"
},
{
data: "tm_adoptanten.Vorname"
},
{
data: "tm_adoptanten.Strasse"
},
{
data: "tm_adoptanten.land"
},
{
data: "tm_adoptanten.PLZ"
},
{
data: "tm_adoptanten.Ort"
},
{
data: "tm_adoptanten.Telefon"
},
{
data: "tm_adoptanten.Handy"
},
{
data: "tm_adoptanten.Fax"
},
{
data: "tm_adoptanten.Email"
},
{
data: "tm_adoptanten.Geburtsdatum",
render: function ( data, type, row ) {
var rowvalueallday = row.tm_adoptanten.Geburtsdatum;
if (rowvalueallday == '0000-00-00') {
var gdat = '0000-01-01';
return (moment(gdat).format("DD.MM.YYYY"));
} else {
return (moment(data).format("DD.MM.YYYY"));
}
}
},
{
data: "tm_adoptanten.Blacklist",
render: function ( data, type, row ) {
if ( type === 'display' ) { //if column data is 1 then set attr to checked, use row id as input id (plus prefix)
return '<input type="checkbox" ' + ((data == 1) ? 'checked' : '') + ' id="input' + row.id + '" class="filter-ck" />';
}
return data;
},
className: "dt-body-center"
},
],
rowCallback: function ( row, data ) {
if ( data.tm_adoptanten.Blacklist != 0 ) {
$('td', row).css('color', 'red');
}
// Set the checked state of the checkbox in the table
$('input.editor-blacklist', row).prop( 'checked', data.tm_adoptanten.Blacklist == 1 );
}
} );
$('#reset').click( function (e) {
e.preventDefault();
table.colReorder.reset();
} );
$('#tm_adoptanten_search tbody').on('click', 'tr', function () {
var id = $('td', this).eq(0).text();
//alert( 'You clicked on '+id+'\'s row' );
window.location = "adopt_show.php?id="+id+"&action=show";
} );
} );
var original_init = $.fn.dataTable.ext.buttons.columnVisibility.init;
$.fn.dataTable.ext.buttons.columnVisibility.init =
function (dt, button, conf) {
var that = this;
original_init.call(this, dt, button, conf);
dt.off('column-reorder.dt' + conf.namespace);
dt.on('column-reorder.dt' + conf.namespace,
function (e, settings, details) {
var col = dt.column(conf.columns);
var btn = button.children() ? button.children() : button;
btn.text(conf._columnText(dt, conf.columns));
that.active(col.visible());
});
};
}(jQuery));
and the sql-statement in adopt_search_processing.php
<?php
require_once("../../models/db-settings.php");
$gsearch = $_GET['suche'];
global $mysqli,$db_prefix;
$query="SELECT
tm_adoptanten.id,
tm_adoptanten.Anrede,
tm_adoptanten.Titel,
tm_adoptanten.Name,
tm_adoptanten.Vorname,
tm_adoptanten.Strasse,
tm_adoptanten.Land,
tm_adoptanten.PLZ,
tm_adoptanten.Ort,
tm_adoptanten.Telefon,
tm_adoptanten.Handy,
tm_adoptanten.Fax,
tm_adoptanten.Email,
tm_adoptanten.Geburtsdatum,
tm_adoptanten.Blacklist
FROM
tm_adoptanten
LEFT JOIN tm_anrede ON tm_anrede.id = tm_adoptanten.Anrede
LEFT JOIN tm_titel ON tm_titel.id = tm_adoptanten.Titel
WHERE tm_adoptanten.Name LIKE '%".$gsearch."%' OR tm_adoptanten.Vorname LIKE '%".$gsearch."%';";
$result = mysqli_query($mysqli, $query) or die('(01)Query failed: ' . mysqli_error($mysqli));
$arr = array();
while ($row = mysqli_fetch_row($result)) {
array_push($arr, $row);
}
$totalrecords = count($arr);
$json = array('sEcho' => '1', 'iTotalRecords' => $totalrecords, 'iTotalDisplayRecords' => $totalrecords, 'aaData' => $arr);
print json_encode($json);
?>
The HTML
<table cellpadding="0" cellspacing="0" border="0" class="display nowrap dt-responsive table table-striped table-bordered table-hover" id="tm_adoptanten_search" width="100%">
<thead>
<tr>
<th>ID</th>
<th><?php echo $trans['Anrede'];?></th>
<th><?php echo $trans['Titel'];?></th>
<th><?php echo $trans['Name'];?></th>
<th><?php echo $trans['Vorname'];?></th>
<th><?php echo $trans['Strasse'];?></th>
<th><?php echo $trans['Land'];?></th>
<th><?php echo $trans['PLZ'];?></th>
<th><?php echo $trans['Ort'];?></th>
<th><?php echo $trans['Telefon'];?></th>
<th><?php echo $trans['Handy'];?></th>
<th><?php echo $trans['Fax'];?></th>
<th><?php echo $trans['Mail'];?></th>
<th><?php echo $trans['Geburtstag'];?></th>
<th>Blacklist</th>
</tr>
</thead>
</table>
It's a closed system, so I can't give you a link.
The debuger show no data, because it is in an endlessloop....
Rappi