在分页jQuery数据表的最后一页上显示一行 [英] Show a row on the last page of a paginated jQuery datatable

查看:217
本文介绍了在分页jQuery数据表的最后一页上显示一行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在单击数据表的最后一页时使隐藏的行可见.如何执行此操作?我找不到获取Jquery Datatable分页的当前页码和最后页码的方法.

I want to make a hidden row visible when the last page of the datatable is clicked.How can I do this? I could not find the method to get the current page number and the last page number of Jquery Datatable pagination.

这是我想要做的,但是我不知道如何获取当前页面和最后一页.

This is what I want to do,but I dont have any idea abt how to get current page and last page.

$( "#paginate_button" ).click(function() {     
if(.......){  //if clicked page number= last page
$( "#hidden_row" ).show();
else
$( "#hidden_row" ).hide();
});

推荐答案

首先,实现众所周知的[fnPagingInfo] [1]插件".例如,将以下内容添加到您的代码中:

First, implement the wellknown [fnPagingInfo][1] "plugin". Eg add the following to your code :

$.fn.dataTableExt.oApi.fnPagingInfo = function ( oSettings ) {
  return {
    "iStart":         oSettings._iDisplayStart,
    "iEnd":           oSettings.fnDisplayEnd(),
    "iLength":        oSettings._iDisplayLength,
    "iTotal":         oSettings.fnRecordsTotal(),
    "iFilteredTotal": oSettings.fnRecordsDisplay(),
    "iPage":          Math.ceil( oSettings._iDisplayStart / oSettings._iDisplayLength ),
    "iTotalPages":    Math.ceil( oSettings.fnRecordsDisplay() / oSettings._iDisplayLength )
  };
}

然后,在fnDrawCallback中应用if条件:

Then, apply the if condition in fnDrawCallback :

"fnDrawCallback": function () {
    var currentPage= this.fnPagingInfo().iPage;     
    if ((+currentPage + +1) == this.fnPagingInfo().iTotalPages) {
    $("#target_id").show();
    }else
    $("#target_id").hide();

    }
});

这篇关于在分页jQuery数据表的最后一页上显示一行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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