我用的是ng2智能 table , 我的问题是过滤器,因为我从 ng2 智能表的 valueprepareFunction 返回了自定义数据,
我有这个......
columns: {
id: {
title: 'Id',
type: 'string'
},
surname: {
title: 'surname',
type: 'string'
},
name: {
title: 'name',
type: 'string'
},
date: {
title: 'date',
valuePrepareFunction: (value) => {
if (!value) return '';
return moment(value).format('DD/MM/YYYY');
},
}
}
该值是从数据库获取的时间戳, 当我尝试从表中过滤时,她通过时间戳进行过滤,但我想要使用这种格式“DD/MM/YYYY”进行过滤。
如何更改过滤器之前时间戳中的搜索输入?
最佳答案
我在 ng2-smart-table 设置中使用 filterFunction 解决了...
data_pratica: {
title: 'date',
type: 'string',
valuePrepareFunction: (value) => {
// example of value.... value = 1543105073896
// value is timeStamp
if (!value) return '';
return moment(value).format('DD/MM/YYYY');
},
filterFunction: (cell?: any, search?: string) => {
// cell? is the value of the cell, in this case is a timeStamp
if (search.length > 0) {
return moment(cell).format('DD/MM/YYYY').match(search);
}
}
}
关于angular - 如何过滤ng2智能表中valuePreparefunction返回的自定义数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53350585/