更改 jquery 数据表显示的默认行数
默认情况下,数据表有 4 种大小的记录显示:10、25、50、100。
A)有办法改变这个吗?我尝试编辑 jquery 文件以将数组更改为 [30,60,90,120] 本身,但这破坏了它。
B) 有没有办法在 jquery 构建时初始化时将此选择器的默认选择大小设置为 50(而不是 10)?
我在文档中找不到这些项目。
By default, datatables has 4 sizes of records to show: 10,25,50,100.
A) Is there a way to change this? I tried editing the jquery file to change the array to [30,60,90,120] itself and this destroyed it.
B) Is there a way to set the default selection size say to 50 (instead of 10) of this selector upon initializing when jquery builds it?
I can't find either of these items in the documentation.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
数据表版本:1.9.4
对我有用的是:-
首先,我搜索了 Jquery.dataTables 文件,该文件主要位于 js 文件夹中。然后我搜索“aLengthMenu”:[10,25,50,100],并根据我的要求进行更改,即“aLengthMenu”:[50,75,100,125]。此后,我搜索“iDisplayLength”,只要其值显示为 10(4 到 5 个位置),我将其更改为 50 并保存。我的索引页面上的下拉列表开始将行选项显示为 50,75,100,125,而不是 10,25,50,100,默认选项选择为 50。
Datatable Version : 1.9.4
What works for me is this:-
First I searched the Jquery.dataTables file which is mostly placed in the js folder. Then I search for "aLengthMenu": [ 10, 25, 50, 100 ], and changed it according to my requirements i.e. "aLengthMenu": [ 50, 75, 100, 125 ]. Thereafter I searched for "iDisplayLength" and wherever its value is shown as 10 (4 to 5 places), I changed it to 50 and save. Dropdown on my index page started showing row option as 50,75,100,125 in place of 10,25,50,100 with default option selected as 50.
[更新,因为这个答案似乎得到了一些意见] -
更新答案:
在更高版本(我相信1.10+)中,API命名约定发生了变化,放弃了匈牙利表示法。我相信旧的约定是为了兼容性而使用别名,但当前的约定是:
因此,更新的答案是:
A)它是
lengthMenu
参数:https://datatables.net/reference/option/lengthMenu例如,以下是我的一组设置:
B) pageLength https://datatables.net/reference/option/pageLength -- 可以选择将其设置为默认值是。
原始答案
A)这是
aLengthMenu
参数:http:// datatables.net/ref#aLengthMenu例如,以下是我的一组设置:
B)
iDisplayLength
-- 将此参数设置为默认值[Update because this answer seems to get some views] --
Updated Answer:
In later versions (I believe 1.10+), the API naming conventions changed, ditching the Hungarian notation. I believe the old conventions are aliased for compatibility, but the current conventions are:
Thus, the updated answers are:
A) it's the
lengthMenu
parameter: https://datatables.net/reference/option/lengthMenuFor example, here's how I have one of mine set:
B) pageLength https://datatables.net/reference/option/pageLength -- optionally set this to whatever your default should be.
Original Answer
A) It's the
aLengthMenu
parameter: http://datatables.net/ref#aLengthMenuFor example, here's how I have one of mine set:
B)
iDisplayLength
-- set this parameter to whatever your default should be数据表 1.10+
使用
lengthMenu
定义可用页面长度列表和可选pageLength
设置初始值页长。如果未指定
pageLength
,则会自动指定设置为lengthMenu
指定的数组中给定的第一个值。< /p>请参阅此 jsFiddle 以获取代码和演示。
数据表 1.9
使用
aLengthMenu
定义可用页面长度的列表和< a href="http://legacy.datatables.net/usage/options#iDisplayLength" rel="nofollow noreferrer">iDisplayLength
设置初始页面长度。请参阅此 jsFiddle 以获取代码和演示。
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
.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.See this jsFiddle for code and demonstration.