bootstrap-table 修复了 header 不工作

bootstrap-table fixed header not working

我已经使用 bootstrap-table 在我的项目中设置了一个 table。除了 tbody 内的滚动条外,一切正常。

那里没有滚动条。我错过了什么?我相信如果 scroll-bar 可见,那么 table 功能的 fixed-header 也应该可以正常工作。

<table id="tblMain" class="table table-bordered table-hover" data-show-refresh="false" data-click-to-select="false" data-single-select="true" data-show-toggle="false" data-show-columns="false" data-cache="false" data-page-number="@Model.CommonVariable" data-url='@Url.Action("Index", "Home")'  data-side-pagination="server" data-pagination="true" data-search="false" data-query-params="queryParams" data-response-handler="respHandler">
    <thead class="table-head">
        <tr>
            <th data-field="id" data-formatter="SomeFunction">Item ID</th>
            <th data-field="name" data-formatter="SomeFunction2">Item Name</th>
            <th data-field="price" data-formatter="SomeFunction3">Item Price</th>
        </tr>
    </thead>
</table>

看看这个 fiddle...

这不是我创建的,但我认为这就是您要找的东西。

    table {
        table-layout:fixed;
    }

    .div-table-content {
      height:150px;
      overflow-y:auto;
    }

您可以将 data-height 选项设置为激活 fixed-header 功能,例如:http://issues.wenzhixin.net.cn/bootstrap-table/.