javascript 数据表:在处理时禁用 first next last last 并显示/搜索记录

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/10911122/
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-10-26 11:27:45  来源:igfitidea点击:

Datatables : disable first next previous last and show / search record when processing

javascriptdatatables

提问by Programmer

I am using Datatables 1.9 version

我正在使用数据表 1.9 版本

var oTable = $('#example').dataTable( {
        "oLanguage": {"sSearch": "Search all columns:",
                      "sLengthMenu": "Display <select><option value='100'>100</option><option value='200'>200</option></select> records per page"
                     },
        "sPaginationType": "full_numbers",
        "bAutoWidth": false,
        "iDisplayStart": 0,
        "iDisplayLength": 2000,
        "bFilter": true,
        "bInfo": true,
        "bSort": true,
        "sScrollX": "100%",
        "sScrollY": "500px",
        "bScrollCollapse": true,
        "bPaginate": true,
        "bSortClasses": true,
        "bLengthChange": true,
        "bProcessing": true,
        "bDestroy": true,
        "bServerSide": true,
        "bDeferRender": true,
        "fnServerParams": function ( aoData ) {
                aoData.push( { "name": "form_data", "value": data } );
        },
        "sAjaxSource": "search.py",
        "fnServerData": function ( sSource, aoData, fnCallback ) {
                $.ajax( {
                                "dataType": 'json',
                                "type": "POST",
                                "url": sSource,
                                "data": aoData,
                                "success": function (json)
                                {
                                        fnCallback(json);
                                        $('html, body').animate({scrollTop:$(document).height()}, 'slow');
                                        document.getElementById("bottom").focus();
                                },
                                "error": function (xhr, error, thrown) {
                                        alert("An Error Occurred.!");
                                }
                });

The issue is that when I run the search and datatables renders "Processing ..." text the "Show .. Search" and first next previous and last button also gets displayed. Is there a way that I defer there display when datatabales has processed or received response from backend.

问题是,当我运行搜索和数据表呈现“处理...”文本“显示..搜索”和第一个下一个上一个和最后一个按钮也被显示。当datatabales处理或收到来自后端的响应时,有没有一种方法可以推迟显示。

采纳答案by Anandhukrishna VR

You should include "bPaginate": false,into the configuration object you pass to your constructor parameters.

您应该将"bPaginate": false,传递给构造函数参数的配置对象包含在内。

As seen here. as it is data table

这里所见。因为它是数据表

回答by Konza

I didn't understand your question completly. If you want to hide those controlls you may try this..

我没有完全理解你的问题。如果你想隐藏那些控件,你可以试试这个..

Datatables comes with controls for filtering and pagination. These can be shown and hidden in a couple of ways (all examples in coffeescript): Way 1

数据表带有用于过滤和分页的控件。这些可以通过几种方式显示和隐藏(所有示例都在 coffeescript 中):方式 1

$("#myTable").dataTable
"bPaginate": false, #hide pagination control
"bFilter": false #hide filter control

Way 2: Use the "sDom" prop

方式二:使用“sDom”道具

$("#myTable").dataTable
"aaData": data
"sDom": 'ft'

Here 'f' means filter and 't' means table, so only show those. Order matters: 'ft' puts the filter on top, whereas 'tf' will put it on bottom.

这里“f”表示过滤器,“t”表示表格,所以只显示它们。顺序很重要:'ft' 将过滤器放在顶部,而 'tf' 将其放在底部。

For more complex and other widgets, see Ref Ref: http://datatables.net/usage/options#sDom

对于更复杂的和其他小部件,请参阅参考文献:http: //datatables.net/usage/options#sDom

I got the answer from this link : https://gist.github.com/1568446

我从这个链接得到了答案:https: //gist.github.com/1568446

回答by kushagra kumar

//Hide DataTables Length
<style>.dataTables_length {
  display: none;
}

</style> //Hide Pagination
<style>.pagination {
  display: none;
}

</style> //Hide DataTables Info
<style>.dataTables_info {
  display: none;
}

</style>

This will work,but i am not recommending this

这会起作用,但我不推荐这样做