Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/422.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript jquery数据表添加行。https://datatables.net_Javascript_Jquery_Datatable - Fatal编程技术网

Javascript jquery数据表添加行。https://datatables.net

Javascript jquery数据表添加行。https://datatables.net,javascript,jquery,datatable,Javascript,Jquery,Datatable,我试图在java脚本数据表()中添加一行 我一直在关注这几页,运气不好 我得到的错误如下所示: 未捕获的TypeError:无法读取未定义的属性“add” 你为什么不试试: ReportTable.row.add(['Test','test','test']).draw(); 因为您已将列名添加到Datatable定义中。将DataTables include脚本替换为以下内容: //cdn.datatables.net/1.10.3/js/jquery.dataTables.min.js

我试图在java脚本数据表()中添加一行

我一直在关注这几页,运气不好

我得到的错误如下所示:

未捕获的TypeError:无法读取未定义的属性“add”


你为什么不试试:

ReportTable.row.add(['Test','test','test']).draw();

因为您已将列名添加到Datatable定义中。

将DataTables include脚本替换为以下内容:

//cdn.datatables.net/1.10.3/js/jquery.dataTables.min.js
我猜您使用的是一个过时的版本,它不包括您试图使用的API

ReportTable=$(“#ReportsTable”)。dataTable( 必须是
ReportTable=$(“#ReportsTable”)。DataTable

您必须重写到以下内容:

$('#ReportsTable').dataTable({
 //"data": Reportdata,
"bLengthChange": false,
"columns": [
  { "data": "name", "sTitle": "Name", "sWidth": "300px"},
  { "data": "type", "sTitle": "Report Type" },
  { "data": "timestamp", "sTitle": "Purchase Date" }
 ]
});

var ReportTable = $('#ReportsTable').dataTable();
ReportTable.row.add("{name:'Test', type:'test', timestamp:'test'}").draw();
$('#ReportsTable').dataTable({
 //"data": Reportdata,
"bLengthChange": false,
"columns": [
  { "data": "name", "sTitle": "Name", "sWidth": "300px"},
  { "data": "type", "sTitle": "Report Type" },
  { "data": "timestamp", "sTitle": "Purchase Date" }
 ]
});

var ReportTable = $('#ReportsTable').dataTable();
ReportTable.row.add("{name:'Test', type:'test', timestamp:'test'}").draw();