jQuery数据表分页大小 [英] jQuery DataTables Pagination Size

查看:120
本文介绍了jQuery数据表分页大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在使用jQuery DataTables插件( http://datatables.net )一段时间,通常我们使用默认大小,使用超级好,bStateSave:true 选项。



但现在我真的需要将分页的大小设置为[10,25,50,100],而我需要这样就可以说[1,2,3]。我设置菜单,设置选项 aLengthMenu:[1,2,3] ,如果我选择其中一个选项,它设置正确的选择量。 / p>

但是在dataTable STARTUP上,它的长度不会设置为1,2,3,而是默认为10


$ b $我错过了哪个选项?
提前感谢

解决方案


  • DataTable 1.10+ / strong>



    使用 lengthMenu 来定义可用页面长度的列表,并且可选 pageLength 设置初始页面长度。



    如果 pageLength 未指定,将自动设置为由 lengthMenu

      var table = $('#example')。DataTable({
    lengthMenu:[[2,4,8,-1],[2,4,8,全部 b $ bpageLength:4
    });

    请参阅这个jsFiddle 代码和演示。








  • DataTables 1.9



    使用 aLengthMenu 来定义可用页面长度列表和 iDisplayLength 设置初始页面长度。

      var table = $('#example')。dataTable({
    aLengthMenu:[[2,4,8,-1],[2,4,8,全部]],
    iDisplayLength:4,
    });

    请参阅这个jsFiddle 代码和演示。



i've been using jQuery DataTables plugin ( http://datatables.net ) for quite some time and usually we're super fine using the default sizes and using "bStateSave": true option.

But now i really need to set the sizing of the pagination not as [10,25,50,100] but rather i need this as let's say [1,2,3]. I get the menu to set like this with setting the option aLengthMenu:[1,2,3] and if i select one of the options it sets the correct selection amount.

But on dataTable STARTUP it doesn't set the length to 1,2,3 but rather to the default '10'

Which option am i missing? Thanks in advance!

解决方案

  • DataTables 1.10+

    Use lengthMenu to define a list of available page lengths and optionally pageLength to set initial page length.

    If pageLength is not specified, it will be automatically set to the first value given in array specified by lengthMenu.

    var table = $('#example').DataTable({
       "lengthMenu": [ [2, 4, 8, -1], [2, 4, 8, "All"] ],
       "pageLength": 4
    });
    

    See this jsFiddle for code and demonstration.


  • DataTables 1.9

    Use aLengthMenu to define a list of available page lengths and iDisplayLength to set initial page length.

    var table = $('#example').dataTable({
       "aLengthMenu": [ [2, 4, 8, -1], [2, 4, 8, "All"] ],
       "iDisplayLength": 4,        
    });
    

    See this jsFiddle for code and demonstration.

这篇关于jQuery数据表分页大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆