jQuery DataTables 分页大小 [英] jQuery DataTables Pagination Size

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

问题描述

我已经使用 jQuery DataTables 插件(http://datatables.net)有一段时间了,通常我们'使用默认大小和使用 "bStateSave": true 选项非常好.

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.

但现在我真的需要将分页的大小设置为 [10,25,50,100] 而不是我需要这个,比如 [1,2,3].我通过设置选项 aLengthMenu:[1,2,3] 来设置菜单,如果我选择其中一个选项,它会设置正确的选择量.

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.

但是在 dataTable STARTUP 上,它没有将长度设置为 1,2,3,而是设置为默认的10"

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!

推荐答案

  • 数据表 1.10+

    使用 lengthMenu 定义可用页面长度的列表和可选 pageLength 设置初始页面长度.

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

    如果没有指定pageLength,会自动设置到 lengthMenu 指定的数组中的第一个值.

    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
    });
    

    有关代码和演示,请参阅此 jsFiddle.

    See this jsFiddle for code and demonstration.

    • 数据表 1.9

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

    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,        
    });
    

    有关代码和演示,请参阅此 jsFiddle.

    See this jsFiddle for code and demonstration.

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

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