我正在尝试修改其中一个示例以自定义单元格:
var oTable = $('#example').dataTable( {
"bProcessing": true,
"sAjaxSource": "sources/deep.txt",
"aoColumns": [
{ "mDataProp": "engine" },
{ "fnRender": function( oObj ) {
return "Test";
} },
{ "mDataProp": "platform.inner" },
{ "mDataProp": "platform.details.0" },
{ "mDataProp": "platform.details.1" }
]
} );
使用类似的来源:
{ "aaData": [
{
"engine": "Trident",
"browser": "Internet Explorer 4.0",
"platform": {
"inner": "Win 95+",
"details": [
"4",
"X"
]
}
},
...
...
数据显示正确但我开始收到“DataTables warning(table id ='example'):从第0行的数据源请求未知参数'1'”
我缺少什么?或者我应该以不同的方式做到这一点?
答案 0 :(得分:5)
在官方支持的帮助下,我找到了答案:
需要定义一个额外的参数以避免该警报:
{ "sDefaultContent": "",
"fnRender": function( oObj ) {
return "Test";
} }
http://datatables.net/forums/discussion/9030/using-fnrender-with-ajax-source-datatable#Item_1
答案 1 :(得分:0)
你确定你的错误不在吗
{ "mDataProp": "platform.details.0" },
{ "mDataProp": "platform.details.1" }
应该是
{ "mDataProp": "platform.details[0]" },
{ "mDataProp": "platform.details[1]" }
因为细节是数组吗?