DataTables:在 Ajax 请求后添加行的问题
DataTables: issue with adding rows after Ajax request
当我使用以下行将服务器中的数据添加到数据 table 时,
allOrder.rows.add(response.orderList).draw();
我收到警告
DataTables warning: table id={id} - Requested unknown parameter 0 for row 0
我的table初始化:
ele.DataTable({
"retrieve": true,
"responsive": false,
"columns": [
{"data": "eOrderNo"},
{"data": "siebelOrderNo"},
{"data": "networkId"},
{"data": "serviceId"},
{"data": "customerName"},
{"data": "orderRef"},
{"data": "ocn"},
{"data": "originator"},
{"data": "custService"},
{"data": "status"},
{"data": "orderType"},
{"data": "productDetails"},
{"data": "createDate"},
{"data": "csd"},
{"data": "crd"},
{"data": "icd"},
{"data": "cpd"},
{"data": "ActualDate"}
],
"scrollY": "300px",
"scrollCollapse": true,
"sScrollX": "100%",
"sScrollXInner": "400%",
"paging": true,
"pageLength": 25,
"lengthMenu": [10, 25, 50, 75, 100],
"pagingType": "simple",
/* for V Scroll */
"bFilter": false,
"bInfo": true,
"bProcessing": true,
"order": [
[10, "desc"]
],
"autoWidth": false,
});
JSON
[
{
"eOrderNo": "000050002",
"siebelOrderNo": "000050002",
"networkId": "",
"serviceId": "",
"customerName": "PIPPO",
"orderRef": "",
"ocn": "",
"originator": "BREZZOLARI",
"custService": "",
"status": "Migrated to OH&P",
"orderType": "New Order",
"productDetails": " Voice Connect",
"createDate": "2000-04-27 20:40:17.0",
"csd": "",
"crd": "",
"icd": "",
"cpd": "2000-05-03 23:00:00.0",
"ActualDate": "2000-10-18 17:52:55.0"
},
{
"eOrderNo": "000083855",
"siebelOrderNo": "000083855",
"networkId": "",
"serviceId": "LON/LON/E1D24282,\nLON/LON/E1D24284, \nLON/LON/E1D24285 (Ceased)",
"customerName": "PAINE WEBBER",
"orderRef": "",
"ocn": "",
"originator": "SHARRON GANDER",
"custService": "",
"status": "Completed",
"orderType": "Cease",
"productDetails": "Customer Related Services",
"createDate": "2002-02-07 13:57:12.0",
"csd": "",
"crd": "2001-12-14 00:00:00.0",
"icd": "",
"cpd": "2002-03-07 00:00:00.0",
"ActualDate": "2002-03-07 00:00:00.0"
},
{
"eOrderNo": "000084305",
"siebelOrderNo": "000084305",
"networkId": "",
"serviceId": "",
"customerName": "PAINE WEBBER",
"orderRef": "MC600",
"ocn": "",
"originator": "PAUL BURTON",
"custService": "",
"status": "Completed",
"orderType": "Cease",
"productDetails": " Link Metro",
"createDate": "2001-04-17 09:11:03.0",
"csd": "",
"crd": "2001-04-14 00:00:00.0",
"icd": "",
"cpd": "2001-05-17 00:00:00.0",
"ActualDate": "2001-05-03 00:00:00.0"
},
{
"eOrderNo": "000084799",
"siebelOrderNo": "000084799",
"networkId": "",
"serviceId": "LON/LON/LE-100779 (ceased)",
"customerName": "INVESTEC",
"orderRef": "",
"ocn": "22593",
"originator": "",
"custService": "",
"status": "Completed",
"orderType": "Cease",
"productDetails": " LANLink Metro",
"createDate": "2002-11-21 16:48:36.0",
"csd": "",
"crd": "2002-11-21 00:00:00.0",
"icd": "",
"cpd": "2003-01-06 06:00:00.0",
"ActualDate": "2002-11-29 00:00:00.0"
},
{
"eOrderNo": "000088037",
"siebelOrderNo": "000088037",
"networkId": "",
"serviceId": "LON/LON/E1-027579",
"customerName": "EVOLUTION CONSULTING GROUP",
"orderRef": "",
"ocn": "",
"originator": "STUART HORINE",
"custService": "",
"status": "Completed",
"orderType": "Modification",
"productDetails": " Voice Line",
"createDate": "2001-01-22 11:06:21.0",
"csd": "",
"crd": "",
"icd": "",
"cpd": "2001-02-12 00:00:00.0",
"ActualDate": "2001-01-22 00:00:00.0"
},
{
"eOrderNo": "000100001",
"siebelOrderNo": "000100001",
"networkId": "",
"serviceId": "DLEI00003",
"customerName": "ECOMP ENGINEERING GMBH",
"orderRef": "",
"ocn": "",
"originator": "HERR WELLER",
"custService": "",
"status": "Closed",
"orderType": "New Order",
"productDetails": " LANLink Metro",
"createDate": "2000-01-03 09:18:32.0",
"csd": "",
"crd": "2000-01-14 23:00:00.0",
"icd": "",
"cpd": "2000-01-14 23:00:00.0",
"ActualDate": "2000-01-13 16:31:38.0"
},
{
"eOrderNo": "000100001/1",
"siebelOrderNo": "000100001/1",
"networkId": "",
"serviceId": "DLEI00003",
"customerName": "NEXTRA DEUTSCHLAND COMMUNICATION GMBH",
"orderRef": "",
"ocn": "OMN01",
"originator": "HERR RUDOLF MORBITZER",
"custService": "",
"status": "Completed",
"orderType": "Cease",
"productDetails": " LANLink Metro",
"createDate": "2001-02-23 09:22:20.0",
"csd": "",
"crd": "2001-03-30 23:00:00.0",
"icd": "",
"cpd": "2001-04-01 23:00:00.0",
"ActualDate": "2001-04-02 16:19:56.0"
},
{
"eOrderNo": "000100002",
"siebelOrderNo": "000100002",
"networkId": "",
"serviceId": "SE0100135-142",
"customerName": " TELECOM STUTTGART",
"orderRef": "",
"ocn": "",
"originator": "LUDWIG MODRA",
"custService": "",
"status": "Completed",
"orderType": "Internal",
"productDetails": " Link Metro",
"createDate": "2000-01-03 09:10:34.0",
"csd": "",
"crd": "",
"icd": "",
"cpd": "2000-01-11 23:00:00.0",
"ActualDate": "2000-01-13 06:55:10.0"
},
{
"eOrderNo": "000100003",
"siebelOrderNo": "000100003",
"networkId": "",
"serviceId": "HE0X01125",
"customerName": "MEDIA CONSULTING JOERG MANDT",
"orderRef": "",
"ocn": "",
"originator": "HERR JOERG MANDT",
"custService": "",
"status": "Closed",
"orderType": "New Order",
"productDetails": " Voice Line",
"createDate": "2000-01-03 09:18:36.0",
"csd": "",
"crd": "",
"icd": "",
"cpd": "2000-01-16 23:00:00.0",
"ActualDate": "2000-08-13 23:00:00.0"
},
{
"eOrderNo": "000100003/1",
"siebelOrderNo": "000100003/1",
"networkId": "",
"serviceId": "HE0X01125",
"customerName": "MEDIA CONSULTING JOERG MANDT",
"orderRef": "",
"ocn": "",
"originator": "HERR JOERG MANDT",
"custService": "",
"status": "Completed",
"orderType": "Cease",
"productDetails": " Voice Line",
"createDate": "2000-08-03 12:16:25.0",
"csd": "",
"crd": "2000-08-03 23:00:00.0",
"icd": "",
"cpd": "2000-08-15 23:00:00.0",
"ActualDate": "2000-08-13 23:00:00.0"
},
{
"eOrderNo": "000100004",
"siebelOrderNo": "000100004",
"networkId": "",
"serviceId": "FE1V11746",
"customerName": " TELECOM FRANKFURT",
"orderRef": "",
"ocn": "",
"originator": "HERR SANDRO INGLESE",
"custService": "",
"status": "Completed",
"orderType": "Internal",
"productDetails": " Link Metro",
"createDate": "2000-01-03 09:22:23.0",
"csd": "",
"crd": "",
"icd": "",
"cpd": "2000-01-23 23:00:00.0",
"ActualDate": "2000-02-02 12:53:57.0"
},
{
"eOrderNo": "000100005",
"siebelOrderNo": "000100005",
"networkId": "",
"serviceId": "FE1S11747",
"customerName": " TELECOM FRANKFURT",
"orderRef": "",
"ocn": "",
"originator": "HERR SANDRO INGLESE",
"custService": "",
"status": "Completed",
"orderType": "Internal",
"productDetails": " Link Metro",
"createDate": "2000-01-03 09:26:12.0",
"csd": "",
"crd": "",
"icd": "",
"cpd": "2000-01-23 23:00:00.0",
"ActualDate": "2000-01-20 07:27:36.0"
},
{
"eOrderNo": "000100006",
"siebelOrderNo": "000100006",
"networkId": "",
"serviceId": "HE0X01126.",
"customerName": "MEDIA CONSULTING JOERG MANDT",
"orderRef": "",
"ocn": "",
"originator": "HERR JOERG MANDT",
"custService": "",
"status": "Closed",
"orderType": "New Order",
"productDetails": " Voice Line",
"createDate": "2000-01-03 09:38:33.0",
"csd": "",
"crd": "",
"icd": "",
"cpd": "2000-01-16 23:00:00.0",
"ActualDate": "2000-08-13 23:00:00.0"
},
{
"eOrderNo": "000100006/1",
"siebelOrderNo": "000100006/1",
"networkId": "",
"serviceId": "HE0X01126",
"customerName": "MEDIA CONSULTING JOERG MANDT",
"orderRef": "",
"ocn": "",
"originator": "HERR JOERG MANDT",
"custService": "",
"status": "Completed",
"orderType": "Cease",
"productDetails": " Voice Line",
"createDate": "2000-08-03 12:20:49.0",
"csd": "",
"crd": "2000-08-03 23:00:00.0",
"icd": "",
"cpd": "2000-08-15 23:00:00.0",
"ActualDate": "2000-08-13 23:00:00.0"
},
{
"eOrderNo": "000100007",
"siebelOrderNo": "000100007",
"networkId": "",
"serviceId": "FE5RI0529",
"customerName": " TELECOM FRANKFURT",
"orderRef": "",
"ocn": "",
"originator": "HERR OLIVER GROSS",
"custService": "",
"status": "Completed",
"orderType": "New Order",
"productDetails": "INTERNAL",
"createDate": "2000-01-03 09:34:31.0",
"csd": "",
"crd": "",
"icd": "",
"cpd": "2000-02-20 23:00:00.0",
"ActualDate": "2000-02-21 07:36:34.0"
},
{
"eOrderNo": "000100008",
"siebelOrderNo": "000100008",
"networkId": "",
"serviceId": "NA",
"customerName": " TELECOM FRANKFURT",
"orderRef": "",
"ocn": "",
"originator": "HERR BRIAN CALLAN",
"custService": "",
"status": "Completed",
"orderType": "Internal",
"productDetails": "INTERNAL",
"createDate": "2000-01-03 09:41:09.0",
"csd": "",
"crd": "2000-01-30 23:00:00.0",
"icd": "",
"cpd": "2000-01-31 23:00:00.0",
"ActualDate": "2000-02-22 17:10:27.0"
},
{
"eOrderNo": "000100009",
"siebelOrderNo": "000100009",
"networkId": "",
"serviceId": "F_IA00053",
"customerName": " TELECOM FRANKFURT",
"orderRef": "",
"ocn": "",
"originator": "HERR JENS MOELLER",
"custService": "",
"status": "Completed",
"orderType": "Internal",
"productDetails": "Others (PW)",
"createDate": "2000-01-03 09:46:59.0",
"csd": "",
"crd": "",
"icd": "",
"cpd": "2000-01-25 23:00:00.0",
"ActualDate": "2000-01-20 14:30:23.0"
},
{
"eOrderNo": "000100011",
"siebelOrderNo": "000100011",
"networkId": "",
"serviceId": "FE1X11748",
"customerName": "AZYX DEUTSCHLAND GMBH",
"orderRef": "",
"ocn": "",
"originator": "HERR HERRWIG",
"custService": "",
"status": "Closed",
"orderType": "New Order",
"productDetails": " Voice Line",
"createDate": "2000-01-03 10:50:19.0",
"csd": "",
"crd": "2000-01-21 23:00:00.0",
"icd": "",
"cpd": "2000-02-10 23:00:00.0",
"ActualDate": "2000-02-11 13:01:59.0"
},
{
"eOrderNo": "000100011/1",
"siebelOrderNo": "000100011/1",
"networkId": "",
"serviceId": "FE1X11748",
"customerName": "AZYX",
"orderRef": "",
"ocn": "AZY01",
"originator": "TBA",
"custService": "",
"status": "Completed",
"orderType": "Cease",
"productDetails": " Voice Line",
"createDate": "2003-04-30 11:16:33.0",
"csd": "2003-04-29 23:00:00.0",
"crd": "2003-04-29 23:00:00.0",
"icd": "",
"cpd": "2003-05-01 07:00:00.0",
"ActualDate": "2003-05-13 14:40:52.0"
},
{
"eOrderNo": "000100013",
"siebelOrderNo": "000100013",
"networkId": "",
"serviceId": "FE1P11864",
"customerName": "CARPENET INFORMATION TECHNOLOGIES GMBH",
"orderRef": "",
"ocn": "",
"originator": "HERR DAVIS",
"custService": "",
"status": "Closed",
"orderType": "New Order",
"productDetails": " Link Metro",
"createDate": "2000-01-03 10:48:03.0",
"csd": "",
"crd": "1999-12-31 23:00:00.0",
"icd": "",
"cpd": "2000-02-20 23:00:00.0",
"ActualDate": "2000-02-21 13:28:33.0"
},
{
"eOrderNo": "000100013/1",
"siebelOrderNo": "000100013/1",
"networkId": "",
"serviceId": "FE1P11864",
"customerName": "CARRIER1 GMBH & CO. KG",
"orderRef": "",
"ocn": "CAR01",
"originator": "FRAU BRIGITTE DAVIS",
"custService": "",
"status": "Completed",
"orderType": "Cease, All",
"productDetails": " Link Metro",
"createDate": "2004-12-06 14:29:00.0",
"csd": "2004-11-28 23:00:00.0",
"crd": "2004-12-31 16:00:00.0",
"icd": "",
"cpd": "2005-01-03 11:00:00.0",
"ActualDate": "2005-02-03 14:56:54.0"
},
{
"eOrderNo": "000100013SH1",
"siebelOrderNo": "000100013SH1",
"networkId": "",
"serviceId": "96W/89002/89002/10421, DA: 11;\n96W/89002/89002/12220; DA72;",
"customerName": "NEUBO HAUSVERWALTUNG GMBH & CO. BETRIEBS KG",
"orderRef": "",
"ocn": "517322",
"originator": "HERR HELMUT SCHLACHTER",
"custService": "",
"status": "Closed",
"orderType": "Upgrade",
"productDetails": " Voice Line",
"createDate": "2002-07-05 10:40:02.0",
"csd": "2002-07-03 23:00:00.0",
"crd": "",
"icd": "",
"cpd": "2002-08-12 07:00:00.0",
"ActualDate": "2002-08-12 11:21:38.0"
},
{
"eOrderNo": "000100013SH1/1",
"siebelOrderNo": "000100013SH1/1",
"networkId": "",
"serviceId": "96W/89002/89002/10421, DA11;\n96W/89002/89002/12220; DA72;",
"customerName": "NEUBO HAUSVERWALTUNG GMBH & CO. BETRIEBS KG",
"orderRef": "",
"ocn": "517322",
"originator": "HERR HELMUT SCHLACHTER",
"custService": "",
"status": "Closed",
"orderType": "Modification",
"productDetails": " Voice Line",
"createDate": "2002-08-05 15:55:25.0",
"csd": "2002-08-04 23:00:00.0",
"crd": "",
"icd": "",
"cpd": "2002-08-25 23:00:00.0",
"ActualDate": "2002-08-26 09:45:04.0"
},
{
"eOrderNo": "000100013SH1/2",
"siebelOrderNo": "000100013SH1/2",
"networkId": "",
"serviceId": "96W/89002/89002/10421, DA11;\n96W/89002/89002/12220; DA72;",
"customerName": "NEUBO HAUSVERWALTUNG GMBH & CO. BETRIEBS KG",
"orderRef": "",
"ocn": "517322",
"originator": "HERR HELMUT SCHLACHTER",
"custService": "",
"status": "Completed",
"orderType": "Cease, All",
"productDetails": " Voice Line",
"createDate": "2004-10-11 10:43:06.0",
"csd": "2004-10-03 23:00:00.0",
"crd": "",
"icd": "",
"cpd": "2004-10-11 11:00:00.0",
"ActualDate": "2004-10-11 10:45:12.0"
},
{
"eOrderNo": "000100014",
"siebelOrderNo": "000100014",
"networkId": "",
"serviceId": "N/A",
"customerName": " TELECOM GMBH",
"orderRef": "",
"ocn": "",
"originator": "THORSTEN KULKE",
"custService": "",
"status": "Completed",
"orderType": "Internal",
"productDetails": "Others (PW)",
"createDate": "2000-01-03 10:56:10.0",
"csd": "",
"crd": "2000-02-03 23:00:00.0",
"icd": "",
"cpd": "2000-04-13 23:00:00.0",
"ActualDate": "2000-04-13 10:59:08.0"
}
]
行绘制在 table 上,但没有数据添加到 table。
我的tableheader如下:
<table id="allOrders" class="table table-hover" cellspacing="0">
<thead>
<th data-toggle="tooltip" title="title description goes here..">eOrderNo</th>
<th data-toggle="tooltip" title="title description goes here..">siebelOrderNo</th>
<th data-toggle="tooltip" title="title description goes here..">networkId</th>
<th data-toggle="tooltip" title="title description goes here..">serviceId</th>
<th data-toggle="tooltip" title="title description goes here..">customerName</th>
<th data-toggle="tooltip" title="title description goes here..">orderRef</th>
<th data-toggle="tooltip" title="title description goes here..">ocn</th>
<th data-toggle="tooltip" title="title description goes here..">originator</th>
<th data-toggle="tooltip" title="title description goes here..">custService</th>
<th data-toggle="tooltip" title="title description goes here..">status</th>
<th data-toggle="tooltip" title="title description goes here..">orderType</th>
<th data-toggle="tooltip" title="title description goes here..">productDetails</th>
<th data-toggle="tooltip" title="title description goes here..">createDate</th>
<th data-toggle="tooltip" title="title description goes here..">csd</th>
<th data-toggle="tooltip" title="title description goes here..">crd</th>
<th data-toggle="tooltip" title="title description goes here..">icd</th>
<th data-toggle="tooltip" title="title description goes here..">cpd</th>
<th data-toggle="tooltip" title="title description goes here..">coltActualDate</th>
</thead>
</table>
FINAL EDIT: My issue was the placement of code that populated the
table. It was in a different scope than the scope where the code of
table initialization was placed, hence it was conflicting with the
original initialization.
检查这个:https://www.datatables.net/manual/tech-notes/4。
在您的案例中,“Diagnosis/Parameter 是一个整数”部分是相关的:
When {parameter} is an integer, DataTables is looking for data from an array. This is usually the case when using DOM sourced data (i.e. the data for the table is read automatically from the document). In this circumstance the requested data doesn't exist in source array - likely because the array isn't long enough. This can occur if:
There is a colspan or rowspan in the tbody of the table, which is not supported by DataTables.
Using columns or columnDefs you have specified more columns than there are in the HTML
The number of cells in the table does not satisfy the equation #cells = #columns * #rows (i.e. there are more columns defined in the header than in the table body, or vice-versa).
您的 html 代码中没有 <tbody>
标记,因此请按照链接文档中的说明添加它。
更新
还要检查一下:在列定义中你有 {"data": "coltActualDate"}
并且在 JSON 数组中你有 "ActualDate": "2000-10-18 17:52:55.0"
。可能它不起作用,因为名称不匹配。
更新 2
我已经用你的代码创建了 JSfiddle,一切正常。
https://jsfiddle.net/uosa3dha/1/
SOLUTION
添加 ajax.dataSrc
并将其设置为空字符串 (''
) 以匹配您的数据结构,如下所示:
ele.DataTable({
ajax: {
url: 'script.php',
dataSrc: ''
},
/* ... skipped ... */
});
来自ajax.dataSrc
选项说明:
Note that if your Ajax source simply returns an array of data to
display, rather than an object, set this parameter to be an empty
string.
NOTES
您的代码还有其他问题
"autoWidth": false
后的尾随逗号
thead
元素内部必须有 tr
标签,将 th
包裹在 tr
. 中
当我使用以下行将服务器中的数据添加到数据 table 时,
allOrder.rows.add(response.orderList).draw();
我收到警告
DataTables warning: table id={id} - Requested unknown parameter 0 for row 0
我的table初始化:
ele.DataTable({
"retrieve": true,
"responsive": false,
"columns": [
{"data": "eOrderNo"},
{"data": "siebelOrderNo"},
{"data": "networkId"},
{"data": "serviceId"},
{"data": "customerName"},
{"data": "orderRef"},
{"data": "ocn"},
{"data": "originator"},
{"data": "custService"},
{"data": "status"},
{"data": "orderType"},
{"data": "productDetails"},
{"data": "createDate"},
{"data": "csd"},
{"data": "crd"},
{"data": "icd"},
{"data": "cpd"},
{"data": "ActualDate"}
],
"scrollY": "300px",
"scrollCollapse": true,
"sScrollX": "100%",
"sScrollXInner": "400%",
"paging": true,
"pageLength": 25,
"lengthMenu": [10, 25, 50, 75, 100],
"pagingType": "simple",
/* for V Scroll */
"bFilter": false,
"bInfo": true,
"bProcessing": true,
"order": [
[10, "desc"]
],
"autoWidth": false,
});
JSON
[
{
"eOrderNo": "000050002",
"siebelOrderNo": "000050002",
"networkId": "",
"serviceId": "",
"customerName": "PIPPO",
"orderRef": "",
"ocn": "",
"originator": "BREZZOLARI",
"custService": "",
"status": "Migrated to OH&P",
"orderType": "New Order",
"productDetails": " Voice Connect",
"createDate": "2000-04-27 20:40:17.0",
"csd": "",
"crd": "",
"icd": "",
"cpd": "2000-05-03 23:00:00.0",
"ActualDate": "2000-10-18 17:52:55.0"
},
{
"eOrderNo": "000083855",
"siebelOrderNo": "000083855",
"networkId": "",
"serviceId": "LON/LON/E1D24282,\nLON/LON/E1D24284, \nLON/LON/E1D24285 (Ceased)",
"customerName": "PAINE WEBBER",
"orderRef": "",
"ocn": "",
"originator": "SHARRON GANDER",
"custService": "",
"status": "Completed",
"orderType": "Cease",
"productDetails": "Customer Related Services",
"createDate": "2002-02-07 13:57:12.0",
"csd": "",
"crd": "2001-12-14 00:00:00.0",
"icd": "",
"cpd": "2002-03-07 00:00:00.0",
"ActualDate": "2002-03-07 00:00:00.0"
},
{
"eOrderNo": "000084305",
"siebelOrderNo": "000084305",
"networkId": "",
"serviceId": "",
"customerName": "PAINE WEBBER",
"orderRef": "MC600",
"ocn": "",
"originator": "PAUL BURTON",
"custService": "",
"status": "Completed",
"orderType": "Cease",
"productDetails": " Link Metro",
"createDate": "2001-04-17 09:11:03.0",
"csd": "",
"crd": "2001-04-14 00:00:00.0",
"icd": "",
"cpd": "2001-05-17 00:00:00.0",
"ActualDate": "2001-05-03 00:00:00.0"
},
{
"eOrderNo": "000084799",
"siebelOrderNo": "000084799",
"networkId": "",
"serviceId": "LON/LON/LE-100779 (ceased)",
"customerName": "INVESTEC",
"orderRef": "",
"ocn": "22593",
"originator": "",
"custService": "",
"status": "Completed",
"orderType": "Cease",
"productDetails": " LANLink Metro",
"createDate": "2002-11-21 16:48:36.0",
"csd": "",
"crd": "2002-11-21 00:00:00.0",
"icd": "",
"cpd": "2003-01-06 06:00:00.0",
"ActualDate": "2002-11-29 00:00:00.0"
},
{
"eOrderNo": "000088037",
"siebelOrderNo": "000088037",
"networkId": "",
"serviceId": "LON/LON/E1-027579",
"customerName": "EVOLUTION CONSULTING GROUP",
"orderRef": "",
"ocn": "",
"originator": "STUART HORINE",
"custService": "",
"status": "Completed",
"orderType": "Modification",
"productDetails": " Voice Line",
"createDate": "2001-01-22 11:06:21.0",
"csd": "",
"crd": "",
"icd": "",
"cpd": "2001-02-12 00:00:00.0",
"ActualDate": "2001-01-22 00:00:00.0"
},
{
"eOrderNo": "000100001",
"siebelOrderNo": "000100001",
"networkId": "",
"serviceId": "DLEI00003",
"customerName": "ECOMP ENGINEERING GMBH",
"orderRef": "",
"ocn": "",
"originator": "HERR WELLER",
"custService": "",
"status": "Closed",
"orderType": "New Order",
"productDetails": " LANLink Metro",
"createDate": "2000-01-03 09:18:32.0",
"csd": "",
"crd": "2000-01-14 23:00:00.0",
"icd": "",
"cpd": "2000-01-14 23:00:00.0",
"ActualDate": "2000-01-13 16:31:38.0"
},
{
"eOrderNo": "000100001/1",
"siebelOrderNo": "000100001/1",
"networkId": "",
"serviceId": "DLEI00003",
"customerName": "NEXTRA DEUTSCHLAND COMMUNICATION GMBH",
"orderRef": "",
"ocn": "OMN01",
"originator": "HERR RUDOLF MORBITZER",
"custService": "",
"status": "Completed",
"orderType": "Cease",
"productDetails": " LANLink Metro",
"createDate": "2001-02-23 09:22:20.0",
"csd": "",
"crd": "2001-03-30 23:00:00.0",
"icd": "",
"cpd": "2001-04-01 23:00:00.0",
"ActualDate": "2001-04-02 16:19:56.0"
},
{
"eOrderNo": "000100002",
"siebelOrderNo": "000100002",
"networkId": "",
"serviceId": "SE0100135-142",
"customerName": " TELECOM STUTTGART",
"orderRef": "",
"ocn": "",
"originator": "LUDWIG MODRA",
"custService": "",
"status": "Completed",
"orderType": "Internal",
"productDetails": " Link Metro",
"createDate": "2000-01-03 09:10:34.0",
"csd": "",
"crd": "",
"icd": "",
"cpd": "2000-01-11 23:00:00.0",
"ActualDate": "2000-01-13 06:55:10.0"
},
{
"eOrderNo": "000100003",
"siebelOrderNo": "000100003",
"networkId": "",
"serviceId": "HE0X01125",
"customerName": "MEDIA CONSULTING JOERG MANDT",
"orderRef": "",
"ocn": "",
"originator": "HERR JOERG MANDT",
"custService": "",
"status": "Closed",
"orderType": "New Order",
"productDetails": " Voice Line",
"createDate": "2000-01-03 09:18:36.0",
"csd": "",
"crd": "",
"icd": "",
"cpd": "2000-01-16 23:00:00.0",
"ActualDate": "2000-08-13 23:00:00.0"
},
{
"eOrderNo": "000100003/1",
"siebelOrderNo": "000100003/1",
"networkId": "",
"serviceId": "HE0X01125",
"customerName": "MEDIA CONSULTING JOERG MANDT",
"orderRef": "",
"ocn": "",
"originator": "HERR JOERG MANDT",
"custService": "",
"status": "Completed",
"orderType": "Cease",
"productDetails": " Voice Line",
"createDate": "2000-08-03 12:16:25.0",
"csd": "",
"crd": "2000-08-03 23:00:00.0",
"icd": "",
"cpd": "2000-08-15 23:00:00.0",
"ActualDate": "2000-08-13 23:00:00.0"
},
{
"eOrderNo": "000100004",
"siebelOrderNo": "000100004",
"networkId": "",
"serviceId": "FE1V11746",
"customerName": " TELECOM FRANKFURT",
"orderRef": "",
"ocn": "",
"originator": "HERR SANDRO INGLESE",
"custService": "",
"status": "Completed",
"orderType": "Internal",
"productDetails": " Link Metro",
"createDate": "2000-01-03 09:22:23.0",
"csd": "",
"crd": "",
"icd": "",
"cpd": "2000-01-23 23:00:00.0",
"ActualDate": "2000-02-02 12:53:57.0"
},
{
"eOrderNo": "000100005",
"siebelOrderNo": "000100005",
"networkId": "",
"serviceId": "FE1S11747",
"customerName": " TELECOM FRANKFURT",
"orderRef": "",
"ocn": "",
"originator": "HERR SANDRO INGLESE",
"custService": "",
"status": "Completed",
"orderType": "Internal",
"productDetails": " Link Metro",
"createDate": "2000-01-03 09:26:12.0",
"csd": "",
"crd": "",
"icd": "",
"cpd": "2000-01-23 23:00:00.0",
"ActualDate": "2000-01-20 07:27:36.0"
},
{
"eOrderNo": "000100006",
"siebelOrderNo": "000100006",
"networkId": "",
"serviceId": "HE0X01126.",
"customerName": "MEDIA CONSULTING JOERG MANDT",
"orderRef": "",
"ocn": "",
"originator": "HERR JOERG MANDT",
"custService": "",
"status": "Closed",
"orderType": "New Order",
"productDetails": " Voice Line",
"createDate": "2000-01-03 09:38:33.0",
"csd": "",
"crd": "",
"icd": "",
"cpd": "2000-01-16 23:00:00.0",
"ActualDate": "2000-08-13 23:00:00.0"
},
{
"eOrderNo": "000100006/1",
"siebelOrderNo": "000100006/1",
"networkId": "",
"serviceId": "HE0X01126",
"customerName": "MEDIA CONSULTING JOERG MANDT",
"orderRef": "",
"ocn": "",
"originator": "HERR JOERG MANDT",
"custService": "",
"status": "Completed",
"orderType": "Cease",
"productDetails": " Voice Line",
"createDate": "2000-08-03 12:20:49.0",
"csd": "",
"crd": "2000-08-03 23:00:00.0",
"icd": "",
"cpd": "2000-08-15 23:00:00.0",
"ActualDate": "2000-08-13 23:00:00.0"
},
{
"eOrderNo": "000100007",
"siebelOrderNo": "000100007",
"networkId": "",
"serviceId": "FE5RI0529",
"customerName": " TELECOM FRANKFURT",
"orderRef": "",
"ocn": "",
"originator": "HERR OLIVER GROSS",
"custService": "",
"status": "Completed",
"orderType": "New Order",
"productDetails": "INTERNAL",
"createDate": "2000-01-03 09:34:31.0",
"csd": "",
"crd": "",
"icd": "",
"cpd": "2000-02-20 23:00:00.0",
"ActualDate": "2000-02-21 07:36:34.0"
},
{
"eOrderNo": "000100008",
"siebelOrderNo": "000100008",
"networkId": "",
"serviceId": "NA",
"customerName": " TELECOM FRANKFURT",
"orderRef": "",
"ocn": "",
"originator": "HERR BRIAN CALLAN",
"custService": "",
"status": "Completed",
"orderType": "Internal",
"productDetails": "INTERNAL",
"createDate": "2000-01-03 09:41:09.0",
"csd": "",
"crd": "2000-01-30 23:00:00.0",
"icd": "",
"cpd": "2000-01-31 23:00:00.0",
"ActualDate": "2000-02-22 17:10:27.0"
},
{
"eOrderNo": "000100009",
"siebelOrderNo": "000100009",
"networkId": "",
"serviceId": "F_IA00053",
"customerName": " TELECOM FRANKFURT",
"orderRef": "",
"ocn": "",
"originator": "HERR JENS MOELLER",
"custService": "",
"status": "Completed",
"orderType": "Internal",
"productDetails": "Others (PW)",
"createDate": "2000-01-03 09:46:59.0",
"csd": "",
"crd": "",
"icd": "",
"cpd": "2000-01-25 23:00:00.0",
"ActualDate": "2000-01-20 14:30:23.0"
},
{
"eOrderNo": "000100011",
"siebelOrderNo": "000100011",
"networkId": "",
"serviceId": "FE1X11748",
"customerName": "AZYX DEUTSCHLAND GMBH",
"orderRef": "",
"ocn": "",
"originator": "HERR HERRWIG",
"custService": "",
"status": "Closed",
"orderType": "New Order",
"productDetails": " Voice Line",
"createDate": "2000-01-03 10:50:19.0",
"csd": "",
"crd": "2000-01-21 23:00:00.0",
"icd": "",
"cpd": "2000-02-10 23:00:00.0",
"ActualDate": "2000-02-11 13:01:59.0"
},
{
"eOrderNo": "000100011/1",
"siebelOrderNo": "000100011/1",
"networkId": "",
"serviceId": "FE1X11748",
"customerName": "AZYX",
"orderRef": "",
"ocn": "AZY01",
"originator": "TBA",
"custService": "",
"status": "Completed",
"orderType": "Cease",
"productDetails": " Voice Line",
"createDate": "2003-04-30 11:16:33.0",
"csd": "2003-04-29 23:00:00.0",
"crd": "2003-04-29 23:00:00.0",
"icd": "",
"cpd": "2003-05-01 07:00:00.0",
"ActualDate": "2003-05-13 14:40:52.0"
},
{
"eOrderNo": "000100013",
"siebelOrderNo": "000100013",
"networkId": "",
"serviceId": "FE1P11864",
"customerName": "CARPENET INFORMATION TECHNOLOGIES GMBH",
"orderRef": "",
"ocn": "",
"originator": "HERR DAVIS",
"custService": "",
"status": "Closed",
"orderType": "New Order",
"productDetails": " Link Metro",
"createDate": "2000-01-03 10:48:03.0",
"csd": "",
"crd": "1999-12-31 23:00:00.0",
"icd": "",
"cpd": "2000-02-20 23:00:00.0",
"ActualDate": "2000-02-21 13:28:33.0"
},
{
"eOrderNo": "000100013/1",
"siebelOrderNo": "000100013/1",
"networkId": "",
"serviceId": "FE1P11864",
"customerName": "CARRIER1 GMBH & CO. KG",
"orderRef": "",
"ocn": "CAR01",
"originator": "FRAU BRIGITTE DAVIS",
"custService": "",
"status": "Completed",
"orderType": "Cease, All",
"productDetails": " Link Metro",
"createDate": "2004-12-06 14:29:00.0",
"csd": "2004-11-28 23:00:00.0",
"crd": "2004-12-31 16:00:00.0",
"icd": "",
"cpd": "2005-01-03 11:00:00.0",
"ActualDate": "2005-02-03 14:56:54.0"
},
{
"eOrderNo": "000100013SH1",
"siebelOrderNo": "000100013SH1",
"networkId": "",
"serviceId": "96W/89002/89002/10421, DA: 11;\n96W/89002/89002/12220; DA72;",
"customerName": "NEUBO HAUSVERWALTUNG GMBH & CO. BETRIEBS KG",
"orderRef": "",
"ocn": "517322",
"originator": "HERR HELMUT SCHLACHTER",
"custService": "",
"status": "Closed",
"orderType": "Upgrade",
"productDetails": " Voice Line",
"createDate": "2002-07-05 10:40:02.0",
"csd": "2002-07-03 23:00:00.0",
"crd": "",
"icd": "",
"cpd": "2002-08-12 07:00:00.0",
"ActualDate": "2002-08-12 11:21:38.0"
},
{
"eOrderNo": "000100013SH1/1",
"siebelOrderNo": "000100013SH1/1",
"networkId": "",
"serviceId": "96W/89002/89002/10421, DA11;\n96W/89002/89002/12220; DA72;",
"customerName": "NEUBO HAUSVERWALTUNG GMBH & CO. BETRIEBS KG",
"orderRef": "",
"ocn": "517322",
"originator": "HERR HELMUT SCHLACHTER",
"custService": "",
"status": "Closed",
"orderType": "Modification",
"productDetails": " Voice Line",
"createDate": "2002-08-05 15:55:25.0",
"csd": "2002-08-04 23:00:00.0",
"crd": "",
"icd": "",
"cpd": "2002-08-25 23:00:00.0",
"ActualDate": "2002-08-26 09:45:04.0"
},
{
"eOrderNo": "000100013SH1/2",
"siebelOrderNo": "000100013SH1/2",
"networkId": "",
"serviceId": "96W/89002/89002/10421, DA11;\n96W/89002/89002/12220; DA72;",
"customerName": "NEUBO HAUSVERWALTUNG GMBH & CO. BETRIEBS KG",
"orderRef": "",
"ocn": "517322",
"originator": "HERR HELMUT SCHLACHTER",
"custService": "",
"status": "Completed",
"orderType": "Cease, All",
"productDetails": " Voice Line",
"createDate": "2004-10-11 10:43:06.0",
"csd": "2004-10-03 23:00:00.0",
"crd": "",
"icd": "",
"cpd": "2004-10-11 11:00:00.0",
"ActualDate": "2004-10-11 10:45:12.0"
},
{
"eOrderNo": "000100014",
"siebelOrderNo": "000100014",
"networkId": "",
"serviceId": "N/A",
"customerName": " TELECOM GMBH",
"orderRef": "",
"ocn": "",
"originator": "THORSTEN KULKE",
"custService": "",
"status": "Completed",
"orderType": "Internal",
"productDetails": "Others (PW)",
"createDate": "2000-01-03 10:56:10.0",
"csd": "",
"crd": "2000-02-03 23:00:00.0",
"icd": "",
"cpd": "2000-04-13 23:00:00.0",
"ActualDate": "2000-04-13 10:59:08.0"
}
]
行绘制在 table 上,但没有数据添加到 table。
我的tableheader如下:
<table id="allOrders" class="table table-hover" cellspacing="0">
<thead>
<th data-toggle="tooltip" title="title description goes here..">eOrderNo</th>
<th data-toggle="tooltip" title="title description goes here..">siebelOrderNo</th>
<th data-toggle="tooltip" title="title description goes here..">networkId</th>
<th data-toggle="tooltip" title="title description goes here..">serviceId</th>
<th data-toggle="tooltip" title="title description goes here..">customerName</th>
<th data-toggle="tooltip" title="title description goes here..">orderRef</th>
<th data-toggle="tooltip" title="title description goes here..">ocn</th>
<th data-toggle="tooltip" title="title description goes here..">originator</th>
<th data-toggle="tooltip" title="title description goes here..">custService</th>
<th data-toggle="tooltip" title="title description goes here..">status</th>
<th data-toggle="tooltip" title="title description goes here..">orderType</th>
<th data-toggle="tooltip" title="title description goes here..">productDetails</th>
<th data-toggle="tooltip" title="title description goes here..">createDate</th>
<th data-toggle="tooltip" title="title description goes here..">csd</th>
<th data-toggle="tooltip" title="title description goes here..">crd</th>
<th data-toggle="tooltip" title="title description goes here..">icd</th>
<th data-toggle="tooltip" title="title description goes here..">cpd</th>
<th data-toggle="tooltip" title="title description goes here..">coltActualDate</th>
</thead>
</table>
FINAL EDIT: My issue was the placement of code that populated the table. It was in a different scope than the scope where the code of table initialization was placed, hence it was conflicting with the original initialization.
检查这个:https://www.datatables.net/manual/tech-notes/4。 在您的案例中,“Diagnosis/Parameter 是一个整数”部分是相关的:
When {parameter} is an integer, DataTables is looking for data from an array. This is usually the case when using DOM sourced data (i.e. the data for the table is read automatically from the document). In this circumstance the requested data doesn't exist in source array - likely because the array isn't long enough. This can occur if:
There is a colspan or rowspan in the tbody of the table, which is not supported by DataTables.
Using columns or columnDefs you have specified more columns than there are in the HTML
The number of cells in the table does not satisfy the equation #cells = #columns * #rows (i.e. there are more columns defined in the header than in the table body, or vice-versa).
您的 html 代码中没有 <tbody>
标记,因此请按照链接文档中的说明添加它。
更新
还要检查一下:在列定义中你有 {"data": "coltActualDate"}
并且在 JSON 数组中你有 "ActualDate": "2000-10-18 17:52:55.0"
。可能它不起作用,因为名称不匹配。
更新 2
我已经用你的代码创建了 JSfiddle,一切正常。 https://jsfiddle.net/uosa3dha/1/
SOLUTION
添加 ajax.dataSrc
并将其设置为空字符串 (''
) 以匹配您的数据结构,如下所示:
ele.DataTable({
ajax: {
url: 'script.php',
dataSrc: ''
},
/* ... skipped ... */
});
来自ajax.dataSrc
选项说明:
Note that if your Ajax source simply returns an array of data to display, rather than an object, set this parameter to be an empty string.
NOTES
您的代码还有其他问题
"autoWidth": false
后的尾随逗号
thead
元素内部必须有tr
标签,将th
包裹在tr
. 中