我已升级到DataTables 1.10,并且无法使用column.data或column.render使用不同的值进行排序和显示。如何在DataTable中使用不同的值进行排序和显示1.10
的数据是这样的:
[
{
"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 warning: table id=reportList - Requested unknown parameter 'reportDateRangeMilliseconds' for row 0. For more information about this error, please see 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/
我也尝试了一系列的其他组合,但没有任何喜悦。任何人都可以拯救我的理智吗?
这最终对我来说真的很有帮助,它比安装排序扩展要容易得多。 +1 – 2017-11-02 18:43:55