I'm using the .data() function in jQuery to attach a set of records, returned from the server, to a DOM element on my page. The records are stored as an array of Objects. The code is as follows:
//Attached returned data to an HTML table element
$('#measTable').data('resultSet', resultSet);
//Get stored data from HTML table element
var results = $('#measTable').data('resultSet');
//Construct the measurement table
data_table = $('#measTable').dataTable({
"bJQueryUI": true,
"sPaginationType": "full_numbers",
"bProcessing": true,
"bDeferRender": true,
"aaData": [ results ],
"aoColumns": [
{ "mDataProp": "Field1" },
{ "mDataProp": "Field2" },
{ "mDataProp": "Field3" },
{ "mDataProp": "Field4" }
]
});
I then fetch the data from the element and proceed to load it into the datatable. But this doens't seem to work and always returns with the error Requested unknown parameter "`Field1" from the data source at row 0. Is it possible to load data into datatables in this manner?
UPDATE:
Here is a sample of the result object array
results =
0: Object
Field1: "2011/04/23"
Field2: 8
Field3: "Hello"
Field4: "World"
__proto__: Object
1: Object
Field1: "2011/03/25"
Field2: 6
Field3: "Hello"
Field4: "Everyone"
__proto__: Object
...etc.