I'm working on an Angular 6 app.
I have a custom component in a ng2-smart-table
that displays properly. I would like to filter them.
The call to the API is done asynchronously and returns a promise.
The filterFunction
parameter doesn't filter my table at all.
settings = {
actions: {
...
},
columns: {
id: {
title: 'Id'
},
organisation_id: {
title: 'Cumstom Field',
type: 'custom',
renderComponent: CustomComponent,
filterFunction: (cell?: any, search?: string) => {
return this.api-service-filter(cell, search)
},
api-service-filter
returns a Promise.
When I log the results in the console I get the proper true
/ false
returns from the API. But it doesn't change the display at all.
Any idea of how I could make this work ? Is it a feature of ng2-smart-table or am I doing something wrong ?
Thanks !
I used a workaround for this, created a local copy of the API response and subscribed to this API call. The filter function then only access the local copy and can be written synchronously.