1

I am using jquery DataTables to bind my JSON data to the Table, however when I specify the JSON object to the 'aaData' option of the DataTable, it throws me this error:

"DataTables warning (table id = 'tblReceipt'): Requested unknown parameter '1' from the data source for row 0"

My JSON object looks like this:

var r = [
    { "Vid": "1", "Receiptno": "AFL123", "Type": "3", "Branch": "AFL", "Date": "23/11/2013" },
    { "Vid": "2", "Receiptno": "AFL124", "Type": "4", "Branch": "AFL", "Date": "24/11/2013" },
    { "Vid": "3", "Receiptno": "AFL125", "Type": "6", "Branch": "AFL", "Date": "25/11/2013" },
];

I am passing it to DataTables like this:

$("#tblReceipt").dataTable({
    "aaData": JSON.stringify(r),
    "bJQueryUI": true,
    "bDestroy": true,
    "iDisplayLength": 50,
    "bProcessing": true,
    "aaSorting": [[0, 'desc']],
    "aoColumns": [
      { "mData": "Vid" },
      { "mData": "Receiptno" },
      { "mData": "Type" },
      { "mData": "Branch" },
      { "mData": "Date" },
    ],
    "oLanguage": {
      "sProcessing": "Fetching Data, Please wait..."
    },
});

Any help would be greatly appreciated!

3
  • Why are you doing stringify for aaData ? Is aaData a string ? Commented Nov 6, 2013 at 11:44
  • Try to remove the last comma. Commented Nov 6, 2013 at 11:47
  • 1
    please mark the answer as accepted since I posted a working demo that proves that the problem is solved Commented Nov 7, 2013 at 8:01

1 Answer 1

1

Just replace "aaData": JSON.stringify(r), with "aaData": r,.
Working demo: http://jsfiddle.net/qMPzh/1/

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.