Search code examples
djangobootstrap-table

Bootstrap-table: Server Side pagination + nextPage method


I'm using Django and the app Bootstrap-table to correctly format my tables.

I've got a lot of data so I'm using a server-side pagination. It's working great.

Now I'd like to implement some method like a nextPage method.

By combining the example jsfiddle of server-side pagination + method nextPage, it doesn't work : Clicking on the button nextPage does nothing even if it's bound to nextPage method:

http://jsfiddle.net/ThePhi/msj2apLb/1/

<button id="button2" class="btn btn-default">nextPage</button>

<table data-toggle="table"
       data-url="http://issues.wenzhixin.net.cn/examples/bootstrap_table/data"
       data-pagination="true"
       data-side-pagination="server"
       data-page-list="[5, 10, 20, 50, 100, 200]"
       data-search="true"
       data-height="300">
    <thead>
    <tr>
        <th data-field="state" data-checkbox="true"></th>
        <th data-field="id" data-align="right" data-sortable="true">Item ID</th>
        <th data-field="name" data-align="center" data-sortable="true">Item Name</th>
        <th data-field="price" data-sortable="true">Item Price</th>
    </tr>
    </thead>
</table>
<script>
    var $table = $('#table'),

        $button2 = $('#button2');
    $(function () {

        $button2.click(function () {
            $table.bootstrapTable('nextPage');
        });

    });
</script>

Solution

  • I forgot to put id="table" ...

    working jsFiddle: http://jsfiddle.net/ThePhi/msj2apLb/1/