Reputation: 101
I use the ng2 smart table, my problem is the filter because i returned the custom data from valueprepareFunction of ng2 smart table,
i Have this....
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');
},
}
}
the value is a timeStamp fetch from the db, when i try to filter from the table, her filter through timestamp but i want filter with this format 'DD/MM/YYYY.
How Can change the search input in timestamp before filter ?
Upvotes: 3
Views: 9439
Reputation: 101
I resolved with filterFunction in ng2-smart-table settings...
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);
}
}
}
Upvotes: 7