javascript - Bootstrap table "item per page" dropdownlist not working - Stack Overflow

I use bootstrap table for present my data. Everything works, but there is dropdown to select number of

I use bootstrap table for present my data.

Everything works, but there is dropdown to select number of items per page

There is my code. Do you have any idea, maybe there is some issues with versions?

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

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

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

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

<script src="//cdnjs.cloudflare/ajax/libs/bootstrap-table/1.11.0/bootstrap-table.min.js"></script>
<script src="//cdnjs.cloudflare/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> ...

I use bootstrap table for present my data.

Everything works, but there is dropdown to select number of items per page

There is my code. Do you have any idea, maybe there is some issues with versions?

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

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

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

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

<script src="//cdnjs.cloudflare./ajax/libs/bootstrap-table/1.11.0/bootstrap-table.min.js"></script>
<script src="//cdnjs.cloudflare./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> ...
Share Improve this question edited Jan 19, 2017 at 18:07 Eric G 2,6171 gold badge16 silver badges22 bronze badges asked Jan 19, 2017 at 17:47 JacekJacek 12.1k26 gold badges76 silver badges128 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 5

Since you are using bootstrap table you can use page pageSize property like:

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

And here a basic codepen example of this script overwriting the data-page-list and data-page-size values:

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

Or another example from their documentation is to use the data-query-params value:

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

And then declare queryParams the way you want it:

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

Example: http://jsfiddle/wenyi/e3nk137y/42/

UPDATE

The code you pasted was missing the bootstrap JavaScript link. That is required for the dropdowns to work correctly. Include that link in your code like so:

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

The codepen has been updated with a working example.

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744269387a4566025.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信