gpt4 book ai didi

jquery - dataTables .row( ) 不是服务器端处理行详细信息的函数

转载 作者:行者123 更新时间:2023-12-03 21:47:16 28 4
gpt4 key购买 nike

 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' );
} );
} );



} );

当我点击打开按钮时出现以下错误:

TypeError: dtable.rows is not a function

我做错了什么?我按照官方网站上的示例进行操作。我找不到类似的问题,所以很奇怪。

最佳答案

我遇到了同样的问题,只是通过堆栈溢出的答案解决了它。使用 DataTable() 而不是 dataTable()。方法 row().child() 不适用于 dataTable()。所以你将拥有:

var dtable = $('#table_echipamente').DataTable( {})

而不是

var dtable = $('#table_echipamente').dataTable( {})

关于jquery - dataTables .row( ) 不是服务器端处理行详细信息的函数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24510679/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com