我使用jquery DataTables将我的JSON数据绑定到Table,但是当我将JSON对象指定为DataTable的'aaData'选项时,它会抛出这个错误:
“DataTables warning(table 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..."
},
});
非常感谢任何帮助!
答案 0 :(得分:1)
只需将"aaData": JSON.stringify(r),
替换为"aaData": r,
即可。
工作演示:http://jsfiddle.net/qMPzh/1/