【发布时间】:2019-07-02 16:50:50
【问题描述】:
我正在使用带有以下环境的 angular-datatable 插件:
- 节点版本:v11.1.0
- 角度版本:7.2.4
- angular-cli 版本:7.3.0
- jquery 版本:3.3.22
- 数据表版本:1.10.13
- 角度数据表版本:^7.0.0
HTML 是:
<div class="col ">
<table datatable [dtOptions]="dtOptions" class="table table-striped" style="font-size: 0.8rem;">
<thead>
<tr class="text-center">
<th scope="col">Coupon Code</th>
<th scope="col">Coupon State</th>
<th scope="col">Issuance Channel</th>
<th scope="col">Create Date</th>
<th scope="col">Expire Date</th>
<th scope="col">Number Of Redemptions</th>
<th scope="col">Redemptions</th>
</tr>
</thead>
<tbody>
<tr class="text-center" *ngFor="let object of allCoupons">
<td scope="col">{{object.couponCode}}</td>
<td scope="col">{{object.couponState}}</td>
<td scope="col">{{object.channel}}</td>
<td
scope="col">{{object.createDate | date: 'dd/MM/yyyy' }}</td>
<td
scope="col">{{object.expireDate }}</td>
<td scope="col"> {{object.redemptions.length}}</td>
<td>
<div class="btn-group btn-group-sm w-100">
<button type="button" class="w-100 btn btn-light fas fa-list-alt "
title="See Redemptions"
(click)="openRedeemModal(content,object.redemptions)">
</button>
</div>
</td>
</tr>
</tbody>
</table>
</div>
dtOptions 是:
dtOptions: DataTables.Settings = {};
ngOnInit() {
this.dtOptions = {
columnDefs: [
{ targets: 3, type: 'date' }
]
};
}
但是,正如您在演示中看到的那样,结果不是按日期排序:
https://angular-datatables-gitter-smpc8z.stackblitz.io
我找不到其他解决问题的方法,我已经尝试了我在网上找到的所有方法。
【问题讨论】:
-
我找到了一些使用 JQuery 的解决方案,但没有一个真正适用于 angular。
标签: angular angular-datatables