指定table显示的数据
单独使用 data
来定义table显示的数据,或者配合使用
columns.dataOption
属性来告诉Datatables怎么从 dota
里获取显示数据
注意,如果指定了
dataOption
属性,table里的dom对象会被覆盖掉
该选项可以是以下类型:
使用二维数组:
$('#example').dataTable( { "data": [ [ "Tiger Nixon", "System Architect", "$3,120", "2011/04/25", "Edinburgh", 5421 ], [ "Garrett Winters", "Director", "$8,422", "2011/07/25", "Edinburgh", 8422 ], // ... ] } );
使用对象数组作为数据源:
$('#example').dataTable( { "data": [ { "name": "Tiger Nixon", "position": "System Architect", "salary": "$3,120", "start_date": "2011/04/25", "office": "Edinburgh", "extn": 5421 }, { "name": "Garrett Winters", "position": "Director", "salary": "5300", "start_date": "2011/07/25", "office": "Edinburgh", "extn": "8422" }, // ... ], "columns": [ { "data": "name" }, { "data": "position" }, { "data": "office" }, { "data": "extn" }, { "data": "start_date" }, { "data": "salary" } ] } );
下面的选项是直接相关的,也可能是您的应用程序的开发非常有用。
Translation from DataTables.net, with permission