Datatables 1.10.2 TypeError: divHeader[0] is undefined
Datatables 1.10.2 TypeError: divHeader[0] is undefined
janke
Posts: 19Questions: 0Answers: 0
Sometimes when i load the page i have this error
TypeError: divHeader[0] is undefined
Thanks if you have reponse !!
I use server side processing whith ajax
mycode :
jQuery.fn.extend({
findPos: function() {
obj = jQuery(this).get(0);
var curleft = obj.offsetLeft || 0;
var curtop = obj.offsetTop || 0;
while (obj = obj.offsetParent) {
curleft += obj.offsetLeft
curtop += obj.offsetTop
}
//return {x:curleft,y:curtop};
return {x: curleft, y: curtop};
}
});
function Resizeinnerx(id_table, delta)
{
ArrowUp = $('#' + id_table).findPos();
var hauteur = ($(window).height() - ArrowUp.y);
//alert (hauteur);
return (hauteur - delta);
}
var oTable;
var hauteur;
$(window).resize(function() {
//console.log($(window).height());
$('.dataTables_scrollBody').css('height', ($(window).height() - 300));
});
$(document).ready(function() {
UpdateClocksLBP()
var oTable = $('#example').DataTable({
"responsive": true,
"processing": true,
"serverSide": true,
"ajax": "scripts/server_processing.php",
"oLanguage": {
"sUrl": "media/FR.txt"
},
//"bStateSave": false,
"pagingType": "full_numbers",
"pageLength": 20
, "lengthMenu": [[10, 20, 40, 60], [10, 20, 40, 60]]
, "scrollY": Resizeinnerx('example', 190) + "px"
, "autoWidth": true
//,"columns":[5]
// ,"order": [ [0,'desc']]
, "columnDefs": [
{"searchable": true, "width": "10%", "targets": [0]},
{"searchable": true, "width": "50%", "targets": [1],
"render": function(data, type, full) {
var cle_mega = full[4]; //row id in the first column
return "<a href='/gds/composants/contexte_maj.php?application_cle_mega=" + cle_mega + "&acte=imprim' target='_blank'>" + full[1] + "</a>";
}},
{"searchable": true, "width": "10%", "targets": [2]},
{"searchable": true, "width": "30%", "targets": [3]},
{"searchable": false, "visible": false, "targets": [4]},
{"searchable": true, "visible": false, "targets": [5], "search": ["value"][3]}
]
, "order": [[0, 'asc'], [1, 'asc'], [2, 'asc']]
/*,"drawCallback": function( settings ) {
var api = this.api();
//console.log( api.search() );
//console.log( api.column().search() );+
if(api.search() !='' || api.column().search() != ''){-
//alert("passe");
}
}
*/
});
//fin oTable defs
$("tfoot th").each(function(i) {
//console.log(i);
if ($(this).is('.datainput'))
{
$("tfoot input").keyup(function() {
/* Filter on the column (the index) of this element */
//oTable.fnFilter(this.value, $("tfoot input").index(this));
k = $("tfoot th").index(this.parentNode) - 4;
//oTable.fnFilter(this.value, k);
oTable
.columns(k)
.search(this.value)
.draw();
});
}
else if ($(this).is('.dataselect'))
{
//this.innerHTML = fnCreateSelect(oTable.fnGetColumnData(i));
$('select', this).change(function() {
//oTable.fnFilter($(this).val(), i);
oTable
.columns(i)
.search(this.value)
.draw();
});
}
});
HTML
<div id="container" style="margin-left: auto;margin-right: auto;width:100%;">
<!--<button id='bouton_raz' title='Réinitialise tout les critères'>Réinitialiser</button>!-->
<div id="dynamic">
<form id='myform' action='null'>
<table class="display cell-border" id="example">
<thead>
<tr>
<th>Code SNI</th>
<th>Nom du Composant</th>
<th>SI</th>
<th>Serveurs</th>
</tr>
</thead>
<tfoot>
<tr>
<th class="datainput">
<input type="text" name="application_code_sni" id="application_code_sni" value="" class="search_init" />
</th>
<th class="datainput"><input type="text" name="application_nom" id="application_nom" class="search_init" /></th>
<th class="dataselect">
<select name="application_id_si" id="application_id_si">
<option value="">Choisir</option>
<option value="1">LBP</option>
<option value="2">RLP</option>
</select>
</th>
<th class="datainput"><input type="text" name="nom_serveur" id="nom_serveur" value="" class="search_init" /></th>
</tr>
</tfoot>
</table>
</form>
</div>
This discussion has been closed.
Replies
I found have this code after table init
I suppress this code and error deasapears