jQuery数据表分页大小 [英] jQuery DataTables Pagination Size
问题描述
我一直在使用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 optionallypageLength
to set initial page length.If
pageLength
is not specified, it will be automatically set to the first value given in array specified bylengthMenu
.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 andiDisplayLength
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屋!