为什么我的格式化JQuery.Datatable格式与文档不同

时间:2016-10-28 12:48:01

标签: jquery asp.net-mvc

为什么我的网页看起来不像桌子:

https://datatables.net/examples/basic_init/zero_configuration.html

@{
    Layout = null;

}

<!DOCTYPE html>

<html>
@*<head>
    <meta name="viewport" content="width=device-width" />
    <title>Employee Index Page</title>
</head>*@
<body>
    <div>
        <h1>Employee Index Page</h1>
        <table id="example" class="display" cellspacing="0" width="100%">
            <thead>
                <tr>
                    <th>Symbol</th>
                    <th>ActualPosition</th>
                    <th>AccountIdent</th>
                </tr>
            </thead>
            <tbody>

                @{
                    var categories = (DataTable)ViewData["MyData"];

                    foreach (DataRow item in categories.Rows)
                    {
                        string symbol = item.Field<string>("Symbol");
                        string actualPositionText = item.Field<long>("ActualPosition").ToString();
                        string accountIdent = item.Field<string>("AccountIdent");

                        <tr>
                            <td>@symbol </td>
                            <td>@actualPositionText</td>
                            <td>@accountIdent </td>
                        </tr>
                    }
                }
            <tbody>
        </table>
        <script type="text/javascript" charset="utf8" src="//code.jquery.com/jquery-1.12.3.js"></script>
        <script type="text/javascript" charset="utf8" src="https://cdn.datatables.net/1.10.12/js/jquery.dataTables.min.js"></script>
        <script>
            $(function(){
            $("#example").dataTable();
            })
        </script>


    </div>

</body>
</html>

这是我的页面:

enter image description here

1 个答案:

答案 0 :(得分:0)

您应该包含CSS文件

<link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/1.10.12/css/jquery.dataTables.min.css">