重置jQuery分页插件中的总页面 [英] Reset total pages in jquery pagination plugin

查看:223
本文介绍了重置jQuery分页插件中的总页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用TwbsPagination插件在我的应用程序中显示分页.当我们在初始化时设置页面大小时,它工作正常.但是,根据搜索结果,我想重设总页数.

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.

当我尝试使用

$('#pagination').twbsPagination({totalPages:10});

它不会重置显示的总页数.

it is not resetting the total pages displayed.

推荐答案

啊,我设法用另一种方式来完成这项工作.由于我将其与JQGrid结合使用,因此我选择了loadComplete事件来修补我的代码.步骤如下:

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.创建一个DIV以容纳(twbs控件的)分页按钮

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

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

2.Crate一个本地js变量以保存当前页面

2.Crated a local js variable to hold current page

var currentPage=1;

3.更新JQgrid的AJAX之前的页码

3.Update page number before AJAX of JQgrid

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

4.在loadComplete上重建分页控件.当用户单击页面时,我正在更新页码(currentPage)并重新加载网格.

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

这篇关于重置jQuery分页插件中的总页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆