我正在关注the example here。使用包含对象的数组。jquery数据表不显示列标题
创建我的数组像这样
historyArray[i] = {
"User": strUserName,
"Timestamp" : date.toString(),
"Latitude" : point.lat,
"Longitude" : point.lng
};
我的DataTable实现循环:
$(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"]
}
});
});
我正确的,但没有列标题获取数据,我失去了什么?
哦,还以为它会动态地拉..反正这个工作:)欢呼 – 2012-07-10 16:23:26
@VinceLowe我认为这取决于数据是如何构成的。我广泛使用了Datatables,并且我偶尔会动态地显示列。例如,如果使用gridview(c#),然后将数据表应用到它,它将从gridview获取标题。此外,如果您指定自己的标题,则可以添加过滤器(如下拉菜单或文本框)。 – Drakkainen 2012-07-10 17:18:07
我硬编码如上,但在我看来,你不应该拼出标题出在HTML ...我张贴[这是重新:动态生成标头](http://alanhollis.com/datatables-net- dynamic-column-headings-ajax-request /)希望能够帮助某人或让它在某个时间点工作...... – bahmait 2014-03-21 16:09:52