1

我正在使用 jquery DataTables 将我的 JSON 数据绑定到表,但是当我将 JSON 对象指定到 DataTable 的“aaData”选项时,它会抛出这个错误:

“DataTables 警告(表 id = 'tblReceipt'):从第 0 行的数据源请求未知参数 '1'”

我的 JSON 对象如下所示:

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" },
];

我将它传递给 DataTables,如下所示:

$("#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..."
    },
});

任何帮助将不胜感激!

4

1 回答 1

1

只需替换"aaData": JSON.stringify(r),"aaData": r,.
工作演示:http: //jsfiddle.net/qMPzh/1/

于 2013-11-06T12:01:16.930 回答