DataTable:如何隐藏分页并仅根据需要显示? [英] DataTable : How to hide the pagination and only show it as need?
本文介绍了DataTable:如何隐藏分页并仅根据需要显示?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有2个使用DataTable jQuery插件的表. 我想知道是否有一种方法可以将我的分页隐藏在桌子的右下角.
I have 2 tables that are using DataTable jQuery Plug-in. I wondering if there is a way to hide my pagination on the bottom right of my table.
- 仅在需要时显示分页.
- 查询结果小于10时隐藏分页.
推荐答案
使用 drawCallback 选项处理DT 绘制事件并根据可用页面显示/隐藏分页控件:
Use drawCallback option to handle DT draw event and show/hide pagination control based on available pages:
$('#table_id').dataTable({
drawCallback: function(settings) {
var pagination = $(this).closest('.dataTables_wrapper').find('.dataTables_paginate');
pagination.toggle(this.api().page.info().pages > 1);
}
})
这篇关于DataTable:如何隐藏分页并仅根据需要显示?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文