简体   繁体   English

jquery dataTable分页没有出现

[英]jquery dataTable pagination not appearing

i am working with http://datatables.net/ within a grails application this is my initialization code: 我正在使用grails应用程序中的http://datatables.net/这是我的初始化代码:

<g:javascript>
    $(document).ready(function () {
       var oTable = $('#projectTable').dataTable({
            "bSort": false,
            "sPaginationType": "full_numbers"
        });

        oTable.columnFilter({
            sPlaceHolder: "head:before",
            aoColumns: [
                { sSelector: "#projectIdFilter" },
                { sSelector: "#projectNameFilter" },
                { sSelector: "#projectStatusFilter", type: "select" },
                { sSelector: "#projectModifiedFilter"},
                { sSelector: "#projectActionablesFilter" }
            ]
        });
    });

    function resetFilters() {
        var oTable = $('#projectTable').dataTable();
        var oSettings = oTable.fnSettings();
        for(iCol = 0; iCol < oSettings.aoPreSearchCols.length; iCol++) {
            oSettings.aoPreSearchCols[iCol].sSearch = '';
        }
        oTable.fnDraw();
        $('#filter_Name').val('');
        $('#filter_Project_ID').val('');
        $('#filter_Modified').val('');
        $('#filter_Status').val('Status');
        $('#filter_Actionables').val('');
    }

</g:javascript>

my testdata covers 30 data rows and works just fine (filtering, clearing filters, etc...) the only issue is, that the pagination will not show up. 我的testdata涵盖了30个数据行并且工作正常(过滤,清除过滤器等等)唯一的问题是,分页不会显示。

分页问题的屏幕截图

as you see: 正如你看到的:

  • pagination is working in the background ( showing 1-1 of 30 ) 分页在后台工作( showing 1-1 of 30
  • First text is appearing, although not clickeable (as currently on first page) 第一个文本出现,虽然不是可以解决的(如目前在第一页)

i have tried a lot of different pagingType, bPaginate, bSort,... things but nothing seems to work. 我已经尝试了很多不同的pagingType,bPaginate,bSort,...但事情似乎没什么用。

Any ideas? 有任何想法吗? issues with the underlying grails application? 底层grails应用程序的问题?

Small addon issue/information: if i remove bSort: false the pagination breaks completely and all projects are listed (1 through 30) on one page. 小插件问题/信息:如果我删除bSort: false ,分页完全中断,所有项目都在一页上列出(1到30)。

For javascript, i've use only sPaginationType to initialize the data table. 对于javascript,我只使用sPaginationType来初始化数据表。
I'm always use this code for data table. 我总是将此代码用于数据表。 Let build the data table step by step. 让我们逐步构建数据表。 Use this code only, then check whether it's working or not. 仅使用此代码,然后检查它是否正常工作。

Note: Please remove all other javascript files other than data table js and css files. 注意:请删除除数据表js和css文件以外的所有其他javascript文件。 I got a issue that data table is not working with jquery calender. 我遇到了一个数据表无法使用jquery日历的问题。 Let try this and let me know. 试试这个让我知道。

    $('#table_name').dataTable({
      "sPaginationType": "full_numbers"
      })
    .columnFilter({sPlaceHolder: "head:before",
      aoColumns: [{type: "text" },{type: "text" },{type: "text" },{type: "text" },{type: "text" },{type: "text" }]
    });

数据表

I found the solution - a mixup of two different jquery versions one included automatically by aui (atlassian user interface) and another manually by me. 我找到了解决方案 - 两个不同的jquery版本的混合,一个由aui(atlassian用户界面)自动包含,另一个由我手动包含。 the wrong one was chosen in the end and led to missing pagination. 最后选择了错误的一个并导致失去分页。

solution therefore: 解决方案:

<script type="text/javascript" charset="utf8" src="//code.jquery.com/jquery-1.10.2.min.js"></script>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM