我已升级到 DataTables 1.10,但无法使用 column.data 或 column.render 使用不同的值进行排序和显示。
数据如下:
[
{
"title":"Overview Report: (2014-07-12 11:49 - 2014-07-12 23:49)",
"reportDateRangeMilliseconds":43200000,
"DateRange":"12 hours"
},
{
"title":"User Overview Report: (2014-07-12)",
"reportDateRangeMilliseconds":86400000,
"DateRange":"1 day"
},
{
"title":"Activity Report: (2014-07-31 23:00 - 2014-08-03 00:00)",
"reportDateRangeMilliseconds":176400000,
"DateRange":"2 days, and 1 hour"
}
]
我想创建一列显示DateRange
和排序使用reportDateRangeMilliseconds
我试过了:
$('#reportList').dataTable({
"data" : reportData,
"columns" : [
{ "title" : "Report Name",
"data" : "title"
},
{ "title" : "Date Range",
"data" : "reportDateRangeMilliseconds",
"render" : {
"display" : "DateRange"
}
}
]
})
但它返回错误:
DataTables 警告:表 id=reportList - 请求第 0 行的未知参数“reportDateRangeMilliseconds”。有关此错误的更多信息,请参阅http://datatables.net/tn/4
见http://jsfiddle.net/scottglew/pmpj9uyb/1/
我也试过:
$('#reportList').dataTable({
"data" : reportData,
"columns" : [
{ "title" : "Report Name",
"data" : "title"
},
{ "title" : "Date Range",
"data" : {
"sort" : "reportDateRangeMilliseconds",
"display" : "DateRange"
}
}
]
})
它不会返回错误,但也不会使用毫秒值正确排序。见http://jsfiddle.net/scottglew/jrnou3p3/2/
我还尝试了一系列其他组合,但没有任何乐趣。谁能拯救我的理智?