带有ASP.NET Razor页面的JQuery bootgrid插件

时间:2018-12-20 09:55:06

标签: jquery asp.net-mvc razor jquery-bootgrid

我在Razor视图中有一个简单的HTML表

 <table id="grid"  class="table table-condensed table-hover table-striped">
            <tr>
                  <th data-column-id="Detail">
        Detail
      </th>
                <th data-column-id="Client_Ref">
                    Client Ref
                </th>
                <th data-column-id="Acc">
                     Acc
                </th>

            </tr>

            @foreach (var item in Model)
            {
                <tr>
                    <td>
  @Html.ActionLink(" ", "Detail", new {
   id = item.KeyOfTransaction},
 new { @class = "btn btn-default glyphicon glyphicon-book" })
            </td>
                    <td>
                        @Html.DisplayFor(modelItem => item.Client_Ref)
                    </td>
                    <td>
                        @Html.DisplayFor(modelItem => item.Acc)
                    </td>

                </tr>
            }

        </table>

当我应用JQuery Bootgrid时,仅显示搜索字段,但整个表都为空

@section Scripts {
    <script>

        $(document).ready(function () {

            $("#grid").bootgrid();
        })

    </script>
}

任何人都知道这里有什么问题吗?我需要过滤数据,对其进行排序,并执行此插件提供的所有其他操作

2 个答案:

答案 0 :(得分:0)

bootgrid插件要求您将表行放入tbody标记中,并将标题行放入thead标记中

<table id="grid" class="table table-condensed table-hover table-striped">
  <thead>
    <tr>
         <th data-column-id="Detail">
        Detail
      </th>
      <th data-column-id="Client_Ref">
        Client Ref
      </th>
      <th data-column-id="Acc">
        Acc
      </th>
     </tr>
  </thead>
  <tbody>
    @foreach (var item in Model) {
    <tr>
<td>
  @Html.ActionLink(" ", "Detail", new {
   id = item.KeyOfTransaction},
 new { @class = "btn btn-default glyphicon glyphicon-book" })
            </td>
      <td>
        @Html.DisplayFor(modelItem => item.Client_Ref)
      </td>
      <td>
        @Html.DisplayFor(modelItem => item.Acc)
      </td>

    </tr>
    }
  </tbody>

</table>

答案 1 :(得分:0)

<thead><tbody>标签丢失

示例

<table id="grid-basic" class="table table-condensed table-hover table-striped">
    <thead>
        <tr>
            <th data-column-id="id" data-type="numeric">ID</th>
            <th data-column-id="sender">Sender</th>
            <th data-column-id="received" data-order="desc">Received</th>
        </tr>
    </thead>
    <tbody>
        <tr>
            <td>10238</td>
            <td>eduardo@pingpong.com</td>
            <td>14.10.2013</td>
        </tr>
        ...
    </tbody>
</table>