Jquery 数据表不显示列标题 [英] Jquery datatables not showing column headings

查看:19
本文介绍了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?

推荐答案

尝试像这样改变你的

元素:

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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆