{hero}

unshift()

自:DataTables 1.10

添加一个或多个项目到 API 实例结果集的开头。

说明

正如 JavaScript 数组一样,由于 DataTables API 对象为“类数组”,因此可以使用此方法向结果集添加项目。将项目“unshift”到 API 实例中将它添加到结果集的开头。如果需要,可以使用 push() 在结果集的末尾添加项目。

此方法是 Javascript Array.prototype.unshift 方法的代理,并作为 DataTables API 的实用方法提供。有关原始方法的更多信息,请参考 unsift 的 Mozilla MDN 文档

类型

函数 unshift( value_1 [, value_2 [, ...] ] )

说明

添加一个或多个项目到 API 实例结果集的开头。

参数
返回值

已修改的 API 实例的长度

示例

向从列数据返回的数组中添加空字符串(例如,可用于构建搜索列表)

1
2
3
4
5
var table = new DataTable('#myTable');
 
var data = table.column(0).data();
 
data.unshift('');

Comments (0)

No comments posted for this page yet. Be the first to contribute!

Post new comment

Contributions in the form of tips, code snippets and suggestions for the above material are very welcome. To post a comment, please use the form below. Text is formatted by Markdown.

To post comments, please sign in to your DataTables account, or register:

Any questions posted here will be deleted without being published.
Please post questions in the Forums. Comments are moderated.