如何过滤从 ng2 智能表中的 valuePreparefunction 返回的自定义数据

Vin*_*iro 2 ng2-smart-table angular

我使用 ng2 智能表,我的问题是过滤器,因为我从 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');
  },
}
Run Code Online (Sandbox Code Playgroud)

}

该值是从数据库中获取的 timeStamp,当我尝试从表中进行过滤时,她通过时间戳进行过滤,但我想要使用这种格式的“DD/MM/YYYY”进行过滤。

如何在过滤器之前更改时间戳中的搜索输入?

Vin*_*iro 6

我在 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);
    }
  }
}
Run Code Online (Sandbox Code Playgroud)