【发布时间】:2014-09-13 12:53:58
【问题描述】:
我正在尝试使用 jQuery / DataTables 创建一个表,并使用 JSON 数据作为源。我已经验证了数据很好。不幸的是,我不断收到此错误:“DataTables 警告(表 id='example'):从第 0 行的数据源请求未知参数 '1'”。我不确定我在这里做错了什么:
JSON
dataSet = [
{
"Month": "October",
"Notices Received": "0",
"Declined Participation": "0",
"Selected Field Reviews": "0",
"Selected File Review": "0",
"Pending": "0",
"Pending Previous Year": "0",
"Controversial": "0",
"GFP Reviews": "0",
"NAD Appeals": "0",
"Mediation Cases": "0",
"Monthly Cost Savings": "$0.00",
"Monthly Expenditure": "$0.00"
},
{
"Month": "November",
"Notices Received": "0",
"Declined Participation": "0",
"Selected Field Reviews": "0",
"Selected File Review": "0",
"Pending": "0",
"Pending Previous Year": "0",
"Controversial": "0",
"GFP Reviews": "0",
"NAD Appeals": "0",
"Mediation Cases": "0",
"Monthly Cost Savings": "$0.00",
"Monthly Expenditure": "$0.00"
},
{
"Month": "December",
"Notices Received": "0",
"Declined Participation": "0",
"Selected Field Reviews": "0",
"Selected File Review": "0",
"Pending": "0",
"Pending Previous Year": "0",
"Controversial": "0",
"GFP Reviews": "0",
"NAD Appeals": "0",
"Mediation Cases": "0",
"Monthly Cost Savings": "$0.00",
"Monthly Expenditure": "$0.00"
}];
JS:
$('#theJson').text(dataSet); //just for testing
$('#example').dataTable( {
"aaData": dataSet,
"aoColumns": [
{ "sTitle": "Month" },
{ "sTitle": "Notices Received" },
{ "sTitle": "Declined Participation" },
{ "sTitle": "Selected Field Reviews"},
{ "sTitle": "Selected File Reviews"},
{ "sTitle": "Pending"},
{ "sTitle": "Pending Previous Year"},
{ "sTitle": "Controversial"},
{ "sTitle": "GFP Reviews"},
{ "sTitle": "NAD Appeals"},
{ "sTitle": "Mediation Cases"},
{ "sTitle": "Monthly Cost Savings"},
{ "sTitle": "Monthly Expenditure"}
]
} );
HTML:
<table width="100%" id="example" border="0" cellspacing="0" cellpadding="0"></table>
我得到的只是错误消息和表头。页脚实际上显示:“显示 4,008 个条目中的 1 到 10 个”,这可能表明它正在查看数据。谢谢!
【问题讨论】:
标签: jquery json jquery-datatables