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" }
]
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With