dataTables .row()不是服务器端处理行详细信息 [英] dataTables .row( ) is not a function servers side proccessing row details

查看:189
本文介绍了dataTables .row()不是服务器端处理行详细信息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

 函数格式(d){
return'全名:< br>'+
'工资:< br>'+
'孩子行可以包含你想要的任何数据,包括链接,图像,内表等。
}

$(function(){
var dtable = $('#table_echipamente')。dataTable({
processing:true,
serverSide:true,
ajax:{
url:inc / table_echipamente.php,
type:POST
},
列:[
{
class:details-control,
orderable:false,
data:null,
defaultContent:
},
{data:beneiar},
{data:distribuit},
{data data_distribuit},
{data:denumire},
{data:nr_inventar_nou},
{data:nr_inventar_vechi},
{data:gestionar},
{data:observatii},
{data:optiuni}
],
:[[1,'asc']]

});

//数组跟踪显示行详细信息的ID
var detai lRows = [];

$('#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();

//从'打开'array
detailRows.splice(idx,1);
} else {
tr.addClass('details');
row.child(format(row.data ))).show();

//添加到'open'数组
if(idx === -1){
detailRows.push(tr.attr ('id'));
}
}
});

//在每个绘图上,循环遍历`detailRows`数组并显示任何子行
dtable.on('draw',function(){
$ .each( detail(R),function(i,id){
$('#'+ id +'td:first-child')trigger('click');
});
});



});

当我点击打开的按钮时,我收到以下错误:


TypeError:dtable.rows不是函数


我在做什么错误?我按照官方网站的例子。我找不到类似的问题,所以很奇怪。

解决方案

我有同样的问题,只是通过一个在堆栈溢出时应答。使用 DataTable()而不是 dataTable()。方法 row()。child()将无法使用 dataTable()。所以你会有:



var dtable = $('#table_echipamente')。DataTable({}) / p>

而不是

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


 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 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.

解决方案

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( {})

instead of

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

这篇关于dataTables .row()不是服务器端处理行详细信息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆