简体   繁体   English

DataTable jQuery插件未显示任何内容

[英]DataTable jQuery plugin not showing anything

I've been trying to get DataTable to work with my MVC 5 project, but I've had no luck. 我一直在尝试让DataTable与我的MVC 5项目一起工作,但是我没有运气。 No CSS is showing on the headers of the columns to even show a hint of DataTable working. 列的标题上没有显示CSS,甚至没有显示DataTable工作的提示。 I've been working on this for about two days now with no success. 我已经为此工作了大约两天,但没有成功。 Any help is appreciated, thanks! 任何帮助表示赞赏,谢谢!

@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")'" />*@

验证视图中提到的路径中是否存在所有.css和.js文件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM