jQuery 数据表引导程序分页 - 只显示上一个/下一个

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

datatables bootstrap pagination - only show previous / next

jqueryruby-on-rails-3datatables

提问by Dudo

Been integrating the jquery DataTables plugin to my rails app, via the rweng/jquery-datatables-rails gem. It's awesome. I even went so far as to style it with bootstrap.

通过 rweng/jquery-datatables-rails gem 将 jquery DataTables 插件集成到我的 rails 应用程序中。这很棒。我什至用 bootstrap 来设计它。

So, I have bootstrap, and kaminari for pagination (not sure if that matters). There is a kaminari-bootstrap gem as well.

所以,我有引导程序和用于分页的 kaminari(不确定这是否重要)。还有一个 kaminari-bootstrap gem。

Anyway, the DataTables table shows previous 1 2 3 4 5 next, and it's just chunky. How can I lose the numbers, and just have previoius next?

无论如何,DataTables 表显示了前一个 1 2 3 4 5 下一个,它只是块状。我怎么能丢掉数字,然后只剩下 previoius 呢?

currently calling datatable with:

当前调用数据表:

jQuery ->
  $('#companyBoxList').dataTable
    sDom: "<'row-fluid'<'span6'l><'span6'f>r>t<'row-fluid'<'span6'i><'span6'p>>"
    sPaginationType: "bootstrap"
    bJQueryUI: true
    bProcessing: true
    bServerSide: true
    sAjaxSource: $('#companyBoxList').data('source')

采纳答案by isherwood

Note that this answer referred to an older version of DataTables. There are now six pagination options:

请注意,此答案指的是旧版本的 DataTables。现在有六个分页选项

numbers- Page number buttons only (1.10.8)
simple- 'Previous' and 'Next' buttons only
simple_numbers- 'Previous' and 'Next' buttons, plus page numbers
full- 'First', 'Previous', 'Next' and 'Last' buttons
full_numbers- 'First', 'Previous', 'Next' and 'Last' buttons, plus page numbers
first_last_numbers- 'First' and 'Last' buttons, plus page numbers

numbers- 仅限页码按钮 (1.10.8)
simple-仅限“上一页”和“下一页”按钮
simple_numbers- “上一页”和“下一页”按钮,加上
完整的页码- “第一条”、“上一条”、“下一条”和“Last”按钮
full_numbers- “First”、“Previous”、“Next”和“Last”按钮,加上页码
first_last_numbers- “First”和“Last”按钮,加上页码



http://www.datatables.net/usage/options

http://www.datatables.net/usage/options

sPaginationType

DataTables features two different built-in pagination interaction methods ('twobutton' or 'fullnumbers') which present different page controls to the end user. Further methods can be added using the API (see below).

分页类型

DataTables 具有两种不同的内置分页交互方法(“twobutton”或“fullnumbers”),它们向最终用户呈现不同的页面控件。可以使用 API 添加更多方法(见下文)。

Update: Apparently the Bootstrap plugin forces its own pagination layout. You could do this instead:

更新:显然 Bootstrap 插件强制其自己的分页布局。你可以这样做:

#my_table .pagination li {display: none;}
#my_table .pagination li.prev, #my_table .pagination li.next {display: inline;}

回答by jteks

You have 6 options:

您有 6 种选择:

  • numbers- Page number buttons only
  • simple- 'Previous' and 'Next' buttons only
  • simple_numbers- 'Previous' and 'Next' buttons, plus page numbers
  • full- 'First', 'Previous', 'Next' and 'Last' buttons
  • full_numbers- 'First', 'Previous', 'Next' and 'Last' buttons, plus page numbers
  • first_last_numbers- 'First' and 'Last' buttons, plus page numbers
  • numbers- 仅限页码按钮
  • simple- 仅“上一个”和“下一个”按钮
  • simple_numbers- “上一个”和“下一个”按钮,以及页码
  • full- “第一个”、“上一个”、“下一个”和“最后一个”按钮
  • full_numbers- “第一个”、“上一个”、“下一个”和“最后一个”按钮,以及页码
  • first_last_numbers- “第一个”和“最后一个”按钮,以及页码

The numbersand first_last_numbersoptions were recently added.

numbersfirst_last_numbers最近添加的选项。

(src: http://www.datatables.net/examples/basic_init/alt_pagination.html)

(源代码:http: //www.datatables.net/examples/basic_init/alt_pagination.html



So in your case :

所以在你的情况下:

// Code jQuery.
$('#companyBoxList').dataTable({
  pagingType: "simple"
});