lorenzofox3 / Smart-Table

Code source of Smart Table module: a table/grid for Angularjs
http://lorenzofox3.github.io/smart-table-website/
1.8k stars 513 forks source link

Smart Table st-search=“” searching in the whole array, not on the displayed table #818

Closed Poloten closed 6 years ago

Poloten commented 6 years ago

I have a JSON data array, (array.id, array.name, array.telephone), I display several values in the table using AngularJS {{array.id}} and {{array.name}}. But if I add a search with st-search = "" it searches for the whole array (including array.phone). How do I search only on the displayed values on a table (array.id, array.name) not the whole array?

lorenzofox3 commented 6 years ago

I am unfraid this is not possible, you'll need to "prepare" you data before you bind it to smart-table in your controller.

const yourData =[ /*...*/];
const toBind = yourData.map(({id,name}) => ({id, name}))