datatables request unknown parameter '0' from data source for row 0
最近学习datatables,遇到这么个问题
“request unknown parameter '0' from data source for row 0”
研究了好长时间终于弄明白了,原来是这样的:
datatables 接收两种格式的数据,一种json格式的二维数组,另一种是json格式的数组对象,
如果是服务器端返回的json格式的数组对象,在js中需要设置mDataProp 这个属性,如:
"aoColumns": [ {"mDataProp":"engine"},
{"mDataProp":"browser"},
{"mDataProp":"platform"},
{"mDataProp":"version"}
]
服务器返回的数据格式如下:
{
"sEcho": 1,
"iTotalRecords": "57",
"iTotalDisplayRecords": "57",
"aaData": [
{
"engine": "Gecko",
"browser": "Firefox 1.0",
"platform": "Win 98+ / OSX.2+",
"version": "1.7"
},
{
"engine": "Gecko",
"browser": "Firefox 1.5",
"platform": "Win 98+ / OSX.2+",
"version": "1.8"
}
]
}
继续研究datatables!!