Reset total pages in jquery pagination plugin

后端 未结 5 473
你的背包
你的背包 2021-02-04 05:42

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 t

5条回答
  •  北恋
    北恋 (楼主)
    2021-02-04 06:13

    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)

    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");
        postData.page = 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('');
        $('#paginationholder').html('
      '); $('#pagination').twbsPagination({ startPage: data.page, totalPages: data.total, visiblePages: 5, onPageClick: function (event, page) { currentPage = page; grid.trigger('reloadGrid'); } }); }

    提交回复
    热议问题