datatables bootstrap pagination - only show previo

2019-04-02 10:41发布

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.

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

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?

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')

2条回答
叼着烟拽天下
2楼-- · 2019-04-02 11:00

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)."

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

#my_table .pagination li {display: none;}
#my_table .pagination li.prev, #my_table .pagination li.next {display: inline;}
查看更多
虎瘦雄心在
3楼-- · 2019-04-02 11:16

You have 4 options:

  • 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

So in your case :

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

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

查看更多
登录 后发表回答