簡體   English   中英

如何過濾從ng2智能表中的valuePreparefunction返回的自定義數據

[英]how filter custom data returned from valuePreparefunction in ng2 smart table

我使用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');
  },
}

}

該值是從數據庫中獲取的timeStamp,當我嘗試從表中進行過濾時,她通過時間戳進行過濾,但是我希望使用“ 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);
    }
  }
}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM