我如何在剃须刀中的表中添加一些页面

时间:2018-11-14 16:13:02

标签: c# asp.net-mvc razor model-view-controller

我创建了带有两个标签的视图。 选项卡之一必须分成多个页面。

不知道如何分页。 我是否需要为每个选项卡使用单独的视图,还是仍可以在一个视图中完成?

您能帮我举一个关于相同视图的例子吗?

    <div class="w3-bar w3-dark-grey">
        <button class="w3-bar-item w3-button tablink w3-red" onclick="openTab(event,'Statistics')">Statistics</button>
        <button class="w3-bar-item w3-button tablink" onclick="openTab(event, 'History')">History</button>
    </div>

    <div id="History" class="w3-container w3-border city" style="display:none">
        <h2>History</h2>
        @helper ShowHistory(Site.classes.HistoryStruct[] aHistory)
        {
        <br>
        <table class="table table-hover table-bordered">
            <thead>
                @if (aHistory == null)
                {
                    <tr></tr>
                }
                else
                {
                    <tr>
                        <th>Username</th>
                        <th>Info</th>
                        <th>Date</th>
                    </tr>
                }
            </thead>
            <tbody id="tblStatistics">
                @{string sClass = "class='divaproved'";
                    for (int i = 0; i < aHistory.Length; i++)
                    {
                        <tr @Html.Raw(sClass)>
                            <td>@aHistory[i].UserName</td>
                            <td>@aHistory[i].Info</td>
                            <td>@aHistory[i].Date</td>
                        </tr>
                    }
                }
            </tbody>
        </table>
}
        <div class="container">
            @ShowHistory(Site.classes.UserAccessDB.aHistory)
        </div>

    </div>

1 个答案:

答案 0 :(得分:0)

如果您只需要对表进行分页,则可以尝试以下js:DataTables

为您需要分页的表提供一个ID,并在页面末尾添加以下代码

$(document).ready( function () 
 {
    $('#myTable').DataTable();
 } 
);
相关问题