1

I am new to Angular smart-table, I would like to know how to make the default st-search not searching the hidden fields.

I found a jsfiddle and modified it to explain: http://fiddle.jshell.net/6pykn5hu/31/

In the fiddle, if you type '3' in the search field it will return one record even though the id is not displayed in the table itself, how to make the id not searchable?

Thanks

Ray Sun
  • 301
  • 2
  • 10

1 Answers1

0

you can use the Array.prototype.map function on your data array to create copies of the objects with only the properties you want and only then provide it to smart-table

example:

var data=[{name: "nick", id: 1}, {name: "bob", id: 2}];

var filteredData = data.map(function(object) {
    return {
        name: object.name
    };
});

// filteredData = [{name: "nick"}, {name: "bob"}]

There are of course a lot of ways to remove unwanted properties from an object How do I remove a property from a JavaScript object?

Community
  • 1
  • 1
svarog
  • 9,477
  • 4
  • 61
  • 77
  • Thanks, but I did already map the properties that I need, however property "id" is an exception, it is needed but should NOT be searchable. – Ray Sun Jul 11 '16 at 17:05
  • You can use `st-safe-src` to keep a copy of the original data while using the mapped version ``
    – svarog Jul 11 '16 at 17:09