jquery – dataTables .row()不是服务器端处理行详细信息

前端之家收集整理的这篇文章主要介绍了jquery – 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' );
      } );
  } );



  } );

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

TypeError: dtable.rows is not a function

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

解决方法

我有同样的问题,只是通过堆栈溢出的答案解决了它。使用DataTable()而不是dataTable()。方法row()。child()将不能与dataTable()一起使用。所以你会有:

var dtable = $(‘#table_echipamente’)。DataTable({})

代替

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

猜你在找的jQuery相关文章