dataTables .row() 不是服务器端处理行细节的函数 [英] dataTables .row( ) is not a function servers side processing row details
本文介绍了dataTables .row() 不是服务器端处理行细节的函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
function format ( d ) {
return 'Full name: <br>'+
'Salary:<br>'+
'The child row can contain any data you wish, including links, images, inner tables etc.';
}
$(function() {
var dtable = $('#table_echipamente').dataTable( {
"processing": true,
"serverSide": true,
"ajax": {
"url": "inc/table_echipamente.php",
"type": "POST"
},
"columns": [
{
"class": "details-control",
"orderable": false,
"data": null,
"defaultContent": ""
},
{ "data": "beneficiar" },
{ "data": "distribuit" },
{ "data": "data_distribuit" },
{ "data": "denumire" },
{ "data": "nr_inventar_nou" },
{ "data": "nr_inventar_vechi" },
{ "data": "gestionar" },
{ "data": "observatii" },
{ "data": "optiuni" }
],
"order": [[1, 'asc']]
});
// Array to track the ids of the details displayed rows
var detailRows = [];
$('#table_echipamente tbody').on( 'click', 'tr td:first-child', function () {
var tr = $(this).closest('tr');
var row = dtable.row( tr );
var idx = $.inArray( tr.attr('id'), detailRows );
if ( row.child.isShown() ) {
tr.removeClass( 'details' );
row.child.hide();
// Remove from the 'open' array
detailRows.splice( idx, 1 );
} else {
tr.addClass( 'details' );
row.child( format( row.data() ) ).show();
// Add to the 'open' array
if ( idx === -1 ) {
detailRows.push( tr.attr('id') );
}
}
} );
// On each draw, loop over the `detailRows` array and show any child rows
dtable.on( 'draw', function () {
$.each( detailRows, function ( i, id ) {
$('#'+id+' td:first-child').trigger( 'click' );
} );
} );
} );
当我点击打开按钮时出现以下错误:
i get the following error when i click on the open button:
TypeError: dtable.rows 不是函数
TypeError: dtable.rows is not a function
我做错了什么?我按照官方网站上的例子.我找不到类似的问题,所以很奇怪.
What am i doing wrong? i followed the example on the official site. I can't find a similar problem so it is very weird.
推荐答案
我遇到了同样的问题,刚刚通过有关堆栈溢出的答案解决了这个问题.使用 DataTable()
而不是 dataTable()
.方法 row().child()
不适用于 dataTable()
.所以你将有:
I had same problem and just got it solved through an answer on stack overflow. Use DataTable()
instead of dataTable()
. Method row().child()
will not work with dataTable()
. So you will have:
var dtable = $('#table_echipamente').DataTable({})
代替
var dtable = $('#table_echipamente').dataTable( {})
这篇关于dataTables .row() 不是服务器端处理行细节的函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文