Krishna Sarma Krishna Sarma - 2 months ago 21x
jQuery Question

Reset total pages in jquery pagination plugin

I am using TwbsPagination plug in for displaying paging in my app. It is working fine when we set the page size while initializing. However, based on the search result, I want to reset the total page count.

When I try using


it is not resetting the total pages displayed.


Ah, I managed to get this work in a different way. Since I am using this in conjunction with JQGrid, I picked loadComplete event to patch my code. Here goes the steps:

1.Create a DIV to hold the paging buttons (of twbs control)

<div id="paginationholder"></div>

2.Crated a local js variable to hold current page

var currentPage=1;

3.Update page number before AJAX of JQgrid

beforeRequest: function () {
    var postData = grid.jqGrid('getGridParam', "postData"); = currentPage;
    postData.rows = $("#rows").val();

4.Rebuild the pagination control on loadComplete. When user clicks on a page, I am updating the page number (currentPage) and reloading the grid.

loadComplete: function (data) {
    $('#paginationholder').html('<ul id="pagination" class="pagination-sm"></ul>');
        visiblePages: 5,
        onPageClick: function (event, page) {
            currentPage = page;