AngularDataTable-日期时间列排序问题
创始人
2024-10-24 00:32:03
0

使用Moment.js库来格式化日期时间字符串,并使用自定义排序函数来对日期时间列进行排序。

示例代码:

  1. 在组件中导入Moment.js库

import * as moment from 'moment';

  1. 在tableOptions中定义日期时间列的排序方法

tableOptions: DataTables.Options = { // ... columns: [ // ... { title: '时间', data: 'datetime', type: 'date', render: (data: any): string => { return moment(data).format('YYYY-MM-DD HH:mm:ss'); }, sortMethod: (a: any, b: any): number => { let aMoment = moment(a, 'YYYY-MM-DD HH:mm:ss'); let bMoment = moment(b, 'YYYY-MM-DD HH:mm:ss'); return aMoment.isBefore(bMoment) ? -1 : aMoment.isAfter(bMoment) ? 1 : 0; } } ] };

  1. 在HTML中展示表格

相关内容

热门资讯

透视透视挂"poke... 透视透视挂"poker world辅助器"详细辅助解密教程(都是是真的有挂);最新版2024是一款经...
透视软件"wepok... 透视软件"wepoker透视破解版"详细辅助安装教程(从来是有挂);小薇(透视辅助)致您一封信;亲爱...
透视免费"拱趴大菠萝... 透视免费"拱趴大菠萝有挂吗"详细辅助安装教程(一贯真的有挂)准备好在拱趴大菠萝有挂吗ia的高塔上攀登...
透视黑科技"aapo... 透视黑科技"aapoker真的假的"详细辅助可靠技巧(固有有挂);1.aapoker真的假的 ai辅...
透视ai代打"智星菠... 透视ai代打"智星菠萝透视"详细辅助存在挂教程(其实真的是有挂);1.智星菠萝透视 ai辅助创建新账...
透视透视"uupok... 1、透视透视"uupoker有透视吗"详细辅助软件教程(本来是真的有挂);详细教程。2、uupoke...
透视科技"wejok... 透视科技"wejoker透视方法"详细辅助透牌教程(其实是真的有挂);大神普及一款德州ai内幕,确定...
透视软件"wepok... 透视软件"wepoker到底有没有透视"详细辅助科技教程(素来真的有挂)科技教程也叫必备教程,这是一...
透视智能ai"pok... 透视智能ai"pokemmo辅助器脚本下载"详细辅助黑科技教程(确实真的是有挂);pokemmo辅助...
透视中牌率"WePo... 透视中牌率"WePoKer辅助器"详细辅助2025新版技巧(素来真的是有挂);支持2-10人实时对战...