akveo / akveo/ng2-smart-table

Stand Alone filter always return "No Data Found" on the first click

Open
#1,006 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
1.6k
Forks
867
PR merge metrics
No merged PRs in 30d

Description

I have been facing this bug,
if i give a stand-alone filter like this

`this.source.setFilter([`
` {`
` field: 'amount',`
` search: dateSearch,`
` filter: (value, dateSearch)=>{`
` return new Date(value) >= dateSearch;`
` }`
`], true, true)`

always return's empty (No Data Found) in the grid,
after deep debugging found the root cause in the file,

**ng2-smart-table/src/ng2-smart-table/components/filter/filter-default.ts**

` onFilter(query: string) {`
` this.source.addFilter({`
` field: this.column.id,`
` search: query,`
**filter: this.column.getFilterFunction(),**
` });`
` }`

this particular line
returns the filter from the **filterFunction** in the DataModel which we define to map the data.

which is not defined so my custom function is not executing, instead it runs the normal search and return's zero elements the data Array, saying

"No Data Found"

in the front-end.

so as a workaround, I have set the filter function this in the DataModel itself.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.