2015-09-01 112 views
0


数据表:更改日期格式

我的JS:

work_date
$(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); }); 

数据的格式为:2015年8月9日
我想将它更改为:2015年9月8日。
date-de.js已加载,columnsDefs配置为写入datatables.net。

它不改变日期的格式,我仍然得到2015-08-09。这可能是我使用Codeigniter 3的问题吗?

回答

1

你可以使用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); 
     } 
    }] 
// ... 
});