数据表:更改日期格式

datatables: change date format


我的 JS:

$(function() {
$("#mytable").dataTable({
    processing: true,
    serverSide: true,
    ajax: {
        "url": JS_BASE_URL + "work/dataTable",
        "type": "POST"
    },
    columns: [
        { data: "customer_name" },
        { data: "work_date" }, 
        { data: "work_time"},
        { data: "work_text"},
    ],
    columnDefs:     {   
        type: 'de_date', targets: 1 }
}).dataTableSearch(500); });

work_date 中的数据格式为:2015-08-09
我想将其更改为:09.08.2015。
date-de.js 已加载,columnsDefs 配置为 datatables.net。

它没有改变日期的格式,我仍然得到 2015-08-09。我使用 Codeigniter 3 会不会有问题?

您可以使用 columnDefs 选项,其中 targets 是从零开始的列号:

this_table = $('#lancers_grid').dataTable({
// ...
columnDefs : [
    {
    targets : 1,
        render : function(this_date){
            //Here you should call the date format function:
            return datejs_format_function(this_date);
        }
    }]
// ...
});