0
我已经看过几个关于此错误的SO问题,但没有一个答案解决了我的问题。DataTables警告:请求未知参数(6)行(0)
HTML
<div id="assign_time_invoice_dialog" title="Select Time" class='assign_time_invoice dialog' style="display:none">
<table id="time_dt" class="display dt_selectable" cellspacing="0" cellpadding="0" width="100%">
<thead>
<tr>
<th>Description</th>
<th>Rate</th>
<th>Date</th>
<th>Length</th>
<th>WIP</th>
<th>Job</th>
</tr>
</thead>
</table>
</div>
jQuery的
$("#assign_time_invoice_dialog").dialog({
resizable: false,
height:600,
width:800,
modal: true,
open: function(event, ui) {
var data = {client_id:invoice_client_id};
if (!dataTableCust) {
dataTableCust = $('#time_dt').DataTable({
'ajax': {
'url': 'ajax_time_dt.php',
'data': data
},
"columns": [
{"data": "timetrack_description"},
{"data": "timetrack_user_rate"},
{"data": "timetrack_start"},
{"data": "timetrack_length"},
{"data": "wip_description"},
{"data": "job_description"}
],
"columnDefs": [
{
"targets": [6],
"visible": false,
"searchable": false,
}
],
"iDisplayLength": 100,
"scrollX": true,
"scrollY": "410px",
"scrollCollapse": true,
"pagingType": "simple",
"oLanguage": {
"sSearch": "Search for time:"
},
});
}
},
buttons : button_options
});
JSON响应
{
"data":[
{
"DT_RowId":"1",
"timetrack_description":"Wednesday timetrack",
"timetrack_user_rate":"100.00",
"timetrack_start":"24\/06\/2015",
"timetrack_length":"10:42",
"wip_description":"Accounts",
"job_description":"fifth test job"
},
{
"DT_RowId":"42",
"timetrack_description":"New one",
"timetrack_user_rate":"80.00",
"timetrack_start":"30\/06\/2015",
"timetrack_length":"01:30",
"wip_description":"iXBRL",
"job_description":"None"
}
]
}
使用这个代码,我得到张贴在标题中的错误。在警报上单击“确定”后,DataTable将按照它应该填充的数据进行填充。检查行也显示分配给每一行的正确ID。那么,为什么我看到错误?
如果我将"targets"
从'6'更改为'5',那么我不再看到错误,但是我也不再看到表中的最后一个'作业'列。
任何想法我在做什么错在这里?
感谢,
不知道我是如何错过的,它是columnDefs。谢谢! – Maxxi