New to dataTables - Initialize and load data question

New to dataTables - Initialize and load data question

ChristopherChristopher Posts: 5Questions: 0Answers: 0
edited December 2012 in DataTables 1.8
I am retrieving JSON using the JQuery $.ajax({ }) call and I am receiving the JSON back to the JSP page. I have created the html for the table in my JSP page as follows:




ID
Name







I have included the JQuery and dataTable links for CSS and JS

In my JQuery - I do the following:

$(document).ready(function() {

var aaData=[];
aaData.push({
"ID": "1000",
"Name": "Mike"
});
aaData.push({
"ID": "11000",
"Name": "Jim"
});
aaData.push({
"ID": "12000",
"Name": "John"
});

$('#example').dataTable( {
"aaData": aaData,
"bJQueryUI": true,
"sPaginationType": "full_numbers"
});

});

I receive NULL values in my table. Does anyone know why the data will not paint?
I was only creating the array on the front end to test the load. I have JSON coming
back to the front-end I will load once I figure out the issue. Am I missing something?

I am seeing the table with the JQuery theme but no data except NULLs and a dialog that appears stating:
DataTables warning (table id = 'example'): Requested unknown parameter '0' from the data source for row 0.

Can anyone help? Thank you

Replies

  • allanallan Posts: 61,420Questions: 1Answers: 10,043 Site admin
    You need to use mData to tell DataTables where to get the column data from. See: http://datatables.net/blog/Extended_data_source_options_with_DataTables

    Allan
  • ChristopherChristopher Posts: 5Questions: 0Answers: 0
    Thank you - that answered my question
This discussion has been closed.