Bootstrap table "item per page" 下拉列表不工作

Bootstrap table "item per page" dropdownlist not working

我使用 bootstrap table 来展示我的数据。

一切正常,但每页有 select 个项目数的下拉列表

这是我的代码。 你有什么想法,也许版本有问题?

<link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" >

<link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/bootstrap-table/1.11.0/bootstrap-table.min.css">
<link rel="stylesheet" href="//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">

<script src="//code.jquery.com/jquery-3.1.1.min.js" integrity="sha256-hVVnYaiADRTO2PzUGmuLJr8BLUSjGIZsDYGmIJLv2b8=" crossorigin="anonymous"></script>

<script src="//code.jquery.com/ui/1.12.1/jquery-ui.min.js" integrity="sha256-VazP97ZCwtekAsvgPBSUwPFKdrwD3unUfSGVYrahUqU="crossorigin="anonymous"></script>

<script src="//cdnjs.cloudflare.com/ajax/libs/bootstrap-table/1.11.0/bootstrap-table.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/bootstrap-table/1.11.0/locale/bootstrap-table-en-US.min.js"></script>
...
<table id="goalsListTable"
       class="table table-striped"
       data-toggle="table" data-url="@Url.Content("~/Goal/GoalListJson")" 
       data-side-pagination="server"
       data-pagination="true"
       data-page-list="[10, 25, 50]"
       data-page-size="25">
    <thead> ...

由于您使用的是 bootstrap table,因此您可以使用页面 pageSize 属性,例如:

<script>
    $('#goalsListTable').bootstrapTable({
        pagination: true,
        pageSize: 25, //your page size here
        pageList: [25, 50, 75, 100]//list of page sizes
    });
</script>

这里是这个脚本覆盖 data-page-listdata-page-size 值的基本代码笔示例:

http://codepen.io/egerrard/pen/qRrEap

或者他们文档中的另一个示例是使用 data-query-params 值:

<table data-toggle="table"
       data-url="https://api.github.com/users/wenzhixin/repos"
       data-query-params="queryParams"
       data-pagination="true"
       data-search="true"
       data-height="300">
</table>

然后按照您想要的方式声明queryParams

function queryParams() {
    return {
        type: 'owner',
        sort: 'updated',
        direction: 'desc',
        per_page: 25,
        page: 1
    };
}

示例:http://jsfiddle.net/wenyi/e3nk137y/42/

更新

您粘贴的代码缺少 bootstrap JavaScript link。这是下拉菜单正常工作所必需的。在您的代码中包含 link,如下所示:

<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>

Codepen 已使用工作示例更新。