jQuery 如何删除数据表中的分页

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/17832742/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-26 20:03:20  来源:igfitidea点击:

how to remove pagination in datatable

jqueryhtmlpaginationdatatables

提问by Toseef Khilji

I am new in jQuery. I have used Datatables in grid but need not pagination.

我是 jQuery 新手。我在网格中使用了数据表,但不需要分页。

There is a list of orders in one page and I show them in a Datatable grid but in bottom I do not want to show pagination. Is there any way to remove or hide pagination from the data table by using a bit customization on the jQuery library.

一页中有订单列表,我将它们显示在数据表网格中,但在底部我不想显示分页。有没有办法通过对 jQuery 库进行一些自定义来从数据表中删除或隐藏分页。

enter image description here

在此处输入图片说明

I tried to customize it but I found very few methods to do it..

我试图自定义它,但我发现很少有方法可以做到这一点..

Thanks in advance.

提前致谢。

回答by nstCactus

You should include "bPaginate": false,into the configuration object you pass to your constructor parameters. As seen here: http://datatables.net/release-datatables/examples/basic_init/filter_only.html

您应该将"bPaginate": false,传递给构造函数参数的配置对象包含在内。如下所示:http: //datatables.net/release-datatables/examples/basic_init/filter_only.html

回答by Gyrocode.com

DISABLE PAGINATION

禁用分页

For DataTables 1.9

对于数据表1.9

Use bPaginateoption to disable pagination.

使用bPaginate选项禁用分页。

$('#example').dataTable({
    "bPaginate": false
});

For DataTables 1.10+

对于数据表1.10+

Use pagingoption to disable pagination.

使用paging选项禁用分页。

$('#example').dataTable({
    "paging": false
});

See this jsFiddlefor code and demonstration.

有关代码和演示,请参阅此 jsFiddle

REMOVE PAGINATION CONTROL AND LEAVE PAGINATION ENABLED

删除分页控制并启用分页

For DataTables 1.9

对于数据表1.9

Use sDomoption to configure which control elements appear on the page.

使用sDom选项来配置哪些控制元素出现在页面上。

$('#example').dataTable({
    "sDom": "lfrti"
});

For DataTables 1.10+

对于数据表1.10+

Use domoption to configure which control elements appear on the page.

使用dom选项来配置哪些控制元素出现在页面上。

$('#example').dataTable({
    "dom": "lfrti"
});

See this jsFiddlefor code and demonstration.

有关代码和演示,请参阅此 jsFiddle

回答by Toseef Khilji

$(document).ready(function () {
            $('#Grid_Id').dataTable({
                "bPaginate": false
            });
        });

i have solved my problem using it.

我已经使用它解决了我的问题。

回答by Muhammad Fahad

It's working

它正在工作

Try below code

试试下面的代码

$('#example').dataTable({
    "bProcessing": true,
    "sAutoWidth": false,
    "bDestroy":true,
    "sPaginationType": "bootstrap", // full_numbers
    "iDisplayStart ": 10,
    "iDisplayLength": 10,
    "bPaginate": false, //hide pagination
    "bFilter": false, //hide Search bar
    "bInfo": false, // hide showing entries
})

回答by Abhishek B Patel

$('#table_id').dataTable({    
    "bInfo": false, //Dont display info e.g. "Showing 1 to 4 of 4 entries"
    "paging": false,//Dont want paging                
    "bPaginate": false,//Dont want paging      
})

Try this code

试试这个代码

回答by Mohsin Shoukat

if you want to remove pagination and but want ordering of dataTable then add this script at the end of your page!

如果您想删除分页,但想要对 dataTable 进行排序,请在页面末尾添加此脚本!

<script>
$(document).ready(function() {        
    $('#table_id').DataTable({
        "paging":   false,
       "info":     false
    } );
      
  } );
</script>

回答by ryanm

Here is an alternative that is an incremental improvement on several other answers. Assuming settings.aLengthMenu is not multi-dimensional (it can be when DataTables has row lengths and labels) and the data will not change after page load (for simple DOM-loaded DataTables), this function can be inserted to eliminate paging. It hides several paging-related classes.

这是一个替代方案,它是对其他几个答案的增量改进。假设settings.aLengthMenu不是多维的(当DataTables有行长和标签时可以)并且页面加载后数据不会改变(对于简单的DOM加载的DataTables),可以插入这个函数来消除分页。它隐藏了几个与分页相关的类。

Perhaps more robust would be setting paging to false inside the function below, however I don't see an API call for that off-hand.

也许在下面的函数中将 paging 设置为 false 会更健壮,但是我没有看到针对该函数的 API 调用。

$('#myTable').on('init.dt', function(evt, settings) {
    if (settings && settings.aLengthMenu && settings.fnRecordsTotal && settings.fnRecordsTotal() < settings.aLengthMenu[0]) {
        // hide pagination controls, fewer records than minimum length
        $(settings.nTableWrapper).find('.dataTables_paginate, .dataTables_length, .dataTables_info').hide();
    }
}).DataTable();