Jquery数据表不显示列标题 [英] Jquery datatables not showing column headings
本文介绍了Jquery数据表不显示列标题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在关注这里的示例。使用一个包含对象的数组
I am following the example here. Using an array containing object.
我在这样一个for循环中创建我的数组
I create my array in a for loop like this
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"]
}
});
});
我正在获取数据,但没有列标题,我是否缺少某些东西?
I am getting the data correctly but with no column headings, am i missing something?
推荐答案
尝试更改< table>
元素,如下所示:
Try to change your <table>
element like this:
<table id=report>
<thead>
<tr>
<th>Header 1</th>
<th>Header 2</th>
</tr>
</thead>
</table>
以这种方式创建标题。如果您在示例页面上单击查看源,您将看到相同的实现。
That way the headers are created. If you click view source on the example page you will see the same implementation.
这篇关于Jquery数据表不显示列标题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文