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
我究竟做错了什么?我按照官方网站上的例子。我找不到类似的问题,所以很奇怪。