我一直在努力让DataTable与我的MVC 5项目合作,但我没有运气。列的标题上没有显示CSS,甚至显示DataTable的工作提示。我已经在这方面工作了大约两天但没有成功。感谢任何帮助,谢谢!
@model IEnumerable<BlahBlahBlah.Models.tbl_Reg_User>
@{
ViewBag.Title = "Index";
}
@section Scripts{
<!-- DataTables CSS -->
<link rel="stylesheet" type="text/css" href="~/Content/DataTables-1.10.3/css/jquery.dataTables.css">
<!-- jQuery -->
<script type="text/javascript" charset="utf8" src="~/Scripts/DataTables-1.10.3/js/jquery.js"></script>
<!-- DataTables -->
<script type="text/javascript" charset="utf8" src="~/Scripts/DataTables-1.10.3/js/jquery.dataTables.js"></script>
<script type="text/javascript" src="http://code.jquery.com/jquery-1.8.2.js"></script>
<script type="text/javascript">
$(document).ready(function () {
$('#thetable').DataTable();
});
</script>
}
<body>
<h2>User List</h2>
<p>
@Html.ActionLink("Create New", "Create")
</p>
@using (Html.BeginForm("CheckBoxAction", "User"))
{
<input type="submit" name="deactivateButton" value="Deactivate Selected Users" onclick="location.href'@Url.Action("CheckBoxAction", "User")'" />
<input type="submit" name="activateButton" value="Activate Selected Users" onclick="location.href'@Url.Action("CheckBoxAction", "User")'" />
<table id="thetable" class="table">
<thead>
<tr>
<th>
Select Users
</th>
<th>
@Html.DisplayNameFor(model => model.ID)
</th>
<th>
@Html.DisplayNameFor(model => model.department)
</th>
<th>
@Html.DisplayNameFor(model => model.FirstName)
</th>
<th>
@Html.DisplayNameFor(model => model.LastName)
</th>
<th>
@Html.DisplayNameFor(model => model.Email)
</th>
<th>
@Html.DisplayNameFor(model => model.UserName)
</th>
<th></th>
</tr>
</thead>
<tbody>
@foreach (var item in Model)
{
<tr>
<td>
<input type="checkbox" name="ids" id="ids" value="@item.ID" />
</td>
<td>
@Html.DisplayFor(modelItem => item.ID)
</td>
<td>
@Html.DisplayFor(modelItem => item.department)
</td>
<td>
@Html.DisplayFor(modelItem => item.FirstName)
</td>
<td>
@Html.DisplayFor(modelItem => item.LastName)
</td>
<td>
@Html.DisplayFor(modelItem => item.Email)
</td>
<td>
@Html.DisplayFor(modelItem => item.UserName)
</td>
<td>
@Html.ActionLink("Edit", "Edit", new { id = item.ID }) |
@Html.ActionLink("Details", "Details", new { id = item.ID }) |
@if (item.suspended)
{
@Html.ActionLink("Activate", "Activate", new { id = item.ID })
}
else
{
@Html.ActionLink("Deactivate", "Deactivate", new { id = item.ID })
}
</td>
</tr>
}
</tbody>
</table>
<br />
<input type="submit" name="deactivateButton" value="Deactivate Selected Users" onclick="location.href'@Url.Action("CheckBoxAction", "User")'" />
<input type="submit" name="activateButton" value="Activate Selected Users" onclick="location.href'@Url.Action("CheckBoxAction", "User")'" />
}
@*<input type="button" value="Deactivate" onclick="location.href'@Url.Action("CheckBoxDeactivate", "User")'" />
<input type="button" value="Activate" onclick="location.href'@Url.Action("CheckBoxActivate", "User")'" />*@
答案 0 :(得分:1)
验证视图中提到的路径中是否存在所有.css和.js文件。