0
我嘗試對自定義日期格式列和所有我發現的dataTables
插件進行排序,但無效。DataTables自定義日期格式排序
予加載這樣的數據:
HTML:
<table id="task-list" class="display" cellspacing="0" width="100%" style="display: none;">
<thead>
<tr>
<th><?php echo $this->translate('th-title'); ?></th>
<th><?php echo $this->translate('th-description'); ?></th>
<th><?php echo $this->translate('th-author'); ?></th>
<th><?php echo $this->translate('th-date'); ?></th>
<th><?php echo $this->translate('th-status'); ?></th>
<th><?php echo $this->translate('th-responsible'); ?></th>
<th><?php echo $this->translate('th-options'); ?></th>
</tr>
</thead>
<tfoot>
<tr>
<th><?php echo $this->translate('th-title'); ?></th>
<th><?php echo $this->translate('th-description'); ?></th>
<th><?php echo $this->translate('th-author'); ?></th>
<th><?php echo $this->translate('th-date'); ?></th>
<th><?php echo $this->translate('th-status'); ?></th>
<th><?php echo $this->translate('th-responsible'); ?></th>
<th><?php echo $this->translate('th-options'); ?></th>
</tr>
</tfoot>
</table>
和JS部分:
$('table#task-list').on('xhr.dt', function (e, settings, json) {
$(document).trigger('task.filter.applied',[trigger, target]);
$(this).show();
}).on('error.dt', function (e, settings, techNote, message) {
alert('error occured');
}).dataTable({
"destroy": true,
"ajax": {
url: $(trigger).prop('href'),
type: 'POST',
data: { filterUser: _this.filterUser },
},
"columns": [
{ "data": "title" },
{ "data": "description" },
{ "data": "author" },
{ "data": "date_created" },
{ "data": "status" },
{ "data": "responsible" },
{ "data": "options" }
],
"columnDefs": [
{ className: "options", "targets": [-1] },
],
"order":[[3,'desc']],
"iDisplayLength": 50,
"fnInitComplete": function() {
$('i.fa[data-dt-action]').tooltip();
PLUGIN.applyButtonAction({ target: 'i.fa[data-dt-action="edit"]', fn: 'Task.edit' });
PLUGIN.applyButtonAction({ target: 'i.fa[data-dt-action="assign"]', fn: 'Task.assign' });
PLUGIN.applyButtonAction({ target: 'i.fa[data-dt-action="status"]', fn: 'Task.status' });
PLUGIN.applyButtonAction({ target: 'a[data-dt-action="view"]', fn: 'Task.view' });
},
language: Dash.dataTables.language
});
在列4(指數3)日期格式爲dd.mm.yyyy, hh:mm
任何想法如何正確地排序?
謝謝!
謝謝,它的作品就像一個魅力:D – 2015-02-10 08:56:31