我在这里按照示例进行操作。使用包含对象的数组。
我在这样的 for 循环中创建我的数组
historyArray[i] = {
"User": strUserName,
"Timestamp" : date.toString(),
"Latitude" : point.lat,
"Longitude" : point.lng
};
我的数据表实现:
$(document).ready(function() {
$('#dynamic').html('<table cellpadding="0" cellspacing="0" border="0" class="display" id="report"></table>');
$('#report').dataTable({
"aaData": historyArray,
"aoColumns": [
{ "mDataProp": "User" },
{ "mDataProp": "Timestamp" },
{ "mDataProp": "Latitude" },
{ "mDataProp": "Longitude" }
],
"bJQueryUI": true,
"sPaginationType": "full_numbers",
"sDom": '<"H"Tfr>t<"F"ip>',
"oTableTools": {
"sSwfPath": "swf/copy_csv_xls_pdf.swf",
"aButtons": ["copy", "csv", "xls", "pdf"]
}
});
});
我得到了正确的数据,但没有列标题,我错过了什么吗?