下面是我的cshtml视图文件中的完整代码。为什么JQuery.Datatable没有渲染,也没有给出错误?
我得到一个很好的网页格式化表。
但它没有被JQuery.Datatable格式化。我可以删除所有的脚本行,它看起来仍然是一样的。
我可能会做错什么。我没有得到任何与JQuery相关的构建错误。
<html>
<head>
<meta name="viewport" content="width=device-width" />
<title>Employee Index Page</title>
<script type="text/javascript" language="javascript" src="~/Scripts/jquery-1.10.2.js">
</script>
<script type="text/javascript" language="javascript" src="~/Scripts/DataTables/jquery.dataTables.js">
</script>
<script >
$(document).ready(function() {
$('#example').DataTable();
});
</script>
</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>
</div>
</body>
</html>
你确定浏览器正在拉下dataTable脚本吗?您在调试器控制台中看到任何错误吗? – Kye
完全没有错误 – ManInMoon
你能否确认数据表和jQuery都已加载? – Terry