更新时间:2023-12-01 19:35:16
可以通过aaData属性传入对象数组,然后使用aoColumns属性定义哪一列应该接收哪些数据
$('#example').dataTable({bProcessing":真,"aaData": data,//<-- 你的对象数组"aoColumns": [{ "mData": "render_engine" },//<-- 在对象内部使用哪些值{mData":浏览器"},{mData":平台"},{ "mData": "enging_version" },{mData":css_grade"}]});
I am using the jquery DataTables plugin on my application and I am really happy so far with the functionality although I would like to pass the data slightly differently to the aaData attribute.
currently it only seems to accept the javascript array as
[
['value','value','value'],
...,
...,
]
I would like to be able to use an object rather than arrays because it will be cleaner and help me extend some filtering I am doing easier. how can I pass it a javascript variable that looks like this ( not loading via AJAX ).
[
{'id':1,'status':0,'name': 'hello world'},
...,
...,
]
Example trying to use sAjaxSource with local variable http://live.datatables.net/utecax/edit#
Example trying to use array of objects with aaData http://live.datatables.net/iyavud/5/edit
You can pass in the array of objects via aaData property, then use aoColumns property to define which column should recieve which data
$('#example').dataTable({
"bProcessing": true,
"aaData": data,// <-- your array of objects
"aoColumns": [
{ "mData": "render_engine" }, // <-- which values to use inside object
{ "mData": "browser" },
{ "mData": "platform" },
{ "mData": "enging_version" },
{ "mData": "css_grade" }
]
});