{hero}

push()

自:数据表 1.10

将一个或更多的项目添加到 API 实例结果集末尾。

说明

正如使用 Javascript 数组,由于 DataTables API 对象“类似数组”,因此可使用此方法向结果集添加项目。将项目 推送到 API 实例就是将其添加至结果集末尾。如果需要,可在结果集开始处使用 unshift() 在结果集开始处添加项目。

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

类型

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

说明

将一个或更多的项目添加到 API 实例结果集末尾。

参数
返回值

修改后的 API 实例的长度

示例

为列的数据添加一个值至一个数组。

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

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.